From e1ccf1b50aaa7a1bcb5f4bd9f9bda4ef7b67b437 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 21 Nov 2022 12:34:48 +1100 Subject: [PATCH] restore the easy url --- packages/core/src/scripts/run/dev.ts | 5 +++-- packages/core/src/scripts/run/start.ts | 14 ++++++++------ packages/core/src/scripts/tests/migrations.test.ts | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/core/src/scripts/run/dev.ts b/packages/core/src/scripts/run/dev.ts index fff2ec56630..ccca79bfc75 100644 --- a/packages/core/src/scripts/run/dev.ts +++ b/packages/core/src/scripts/run/dev.ts @@ -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, diff --git a/packages/core/src/scripts/run/start.ts b/packages/core/src/scripts/run/start.ts index dd51fc48d09..44e5220caf3 100644 --- a/packages/core/src/scripts/run/start.ts +++ b/packages/core/src/scripts/run/start.ts @@ -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})`); }); }; diff --git a/packages/core/src/scripts/tests/migrations.test.ts b/packages/core/src/scripts/tests/migrations.test.ts index 935d50dfd5e..31a7a49a9f2 100644 --- a/packages/core/src/scripts/tests/migrations.test.ts +++ b/packages/core/src/scripts/tests/migrations.test.ts @@ -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 @@ -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.