Skip to content

Commit

Permalink
restore the easy url
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Nov 21, 2022
1 parent e101b66 commit e1ccf1b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/scripts/run/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,9 @@ export const dev = async (cwd: string, shouldDropDatabase: boolean) => {

const server = httpServer.listen(httpOptions, (err?: any) => {
if (err) throw err;
// We start initialising Keystone after the dev server is ready,
console.log(`⭐️ Server listening on ${httpOptions.host}, port ${httpOptions.port}`);

const fastUrl = httpOptions.host === '::' ? `http://localhost:${httpOptions.port}/` : `http://${httpOptions.host}:${httpOptions.port}/`
console.log(`⭐️ Server listening on ${httpOptions.host}, port ${httpOptions.port} (${fastUrl})`);
console.log(`⭐️ GraphQL API available at ${config.graphql?.path || '/api/graphql' }`);

// Don't start initialising Keystone until the dev server is ready,
Expand Down
14 changes: 8 additions & 6 deletions packages/core/src/scripts/run/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,28 @@ export const start = async (cwd: string) => {
console.log(`✅ Admin UI ready`);
}

const options: ListenOptions = {
const httpOptions: ListenOptions = {
host: '::', // the default for nodejs httpServer
port: 3000,
};

if (config?.server && 'port' in config.server) {
options.port = config.server.port;
httpOptions.port = config.server.port;
}

if (config?.server && 'options' in config.server && config.server.options) {
Object.assign(options, config.server.options);
Object.assign(httpOptions, config.server.options);
}

// preference env.PORT if supplied
if ('PORT' in process.env) {
options.port = parseInt(process.env.PORT || '');
httpOptions.port = parseInt(process.env.PORT || '');
}

httpServer.listen(options, (err?: any) => {
httpServer.listen(httpOptions, (err?: any) => {
if (err) throw err;
console.log(`⭐️ Server listening on ${options.host}, port ${options.port}`);

const fastUrl = httpOptions.host === '::' ? `http://localhost:${httpOptions.port}/` : `http://${httpOptions.host}:${httpOptions.port}/`
console.log(`⭐️ Server listening on ${httpOptions.host}, port ${httpOptions.port} (${fastUrl})`);
});
};
4 changes: 2 additions & 2 deletions packages/core/src/scripts/tests/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ model Todo {
`);

expect(recording()).toEqual(`✨ Starting Keystone
⭐️ Server listening on ::, port 3000
⭐️ Server listening on ::, port 3000 (http://localhost:3000/)
⭐️ GraphQL API available at /api/graphql
✨ Generating GraphQL and Prisma schemas
✨ sqlite database "app.db" created at file:./app.db
Expand All @@ -109,7 +109,7 @@ describe('useMigrations: false', () => {

expect(recording()).toMatchInlineSnapshot(`
"✨ Starting Keystone
⭐️ Server listening on ::, port 3000
⭐️ Server listening on ::, port 3000 (http://localhost:3000/)
⭐️ GraphQL API available at /api/graphql
✨ Generating GraphQL and Prisma schemas
✨ The database is already in sync with the Prisma schema.
Expand Down

0 comments on commit e1ccf1b

Please sign in to comment.