From 7d3e1e3ef73d9a0862df7e26e044dc129f9e4dbb Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Sun, 23 Mar 2025 12:02:16 +0530 Subject: [PATCH] Refactor server startup in templates to use info callback --- apps/cli/package.json | 5 +---- apps/cli/template/base/packages/server/src/index.ts | 7 +++---- apps/cli/template/with-auth/packages/server/src/index.ts | 7 +++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/apps/cli/package.json b/apps/cli/package.json index 0cb76ef..f34c063 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -22,10 +22,7 @@ "test": "vitest run", "prepublishOnly": "npm run build" }, - "files": [ - "dist", - "template" - ], + "files": ["dist", "template"], "dependencies": { "@clack/prompts": "^0.10.0", "commander": "^13.1.0", diff --git a/apps/cli/template/base/packages/server/src/index.ts b/apps/cli/template/base/packages/server/src/index.ts index 2ce846e..df4f3cd 100644 --- a/apps/cli/template/base/packages/server/src/index.ts +++ b/apps/cli/template/base/packages/server/src/index.ts @@ -33,10 +33,9 @@ app.get("/healthCheck", (c) => { return c.text("OK"); }); -const port = 3000; -console.log(`Server is running on http://localhost:${port}`); - serve({ fetch: app.fetch, - port, + port: 3000, +}, (info) => { + console.log(`Server is running on http://localhost:${info.port}`) }); diff --git a/apps/cli/template/with-auth/packages/server/src/index.ts b/apps/cli/template/with-auth/packages/server/src/index.ts index 4496748..335c506 100644 --- a/apps/cli/template/with-auth/packages/server/src/index.ts +++ b/apps/cli/template/with-auth/packages/server/src/index.ts @@ -38,10 +38,9 @@ app.get("/healthCheck", (c) => { return c.text("OK"); }); -const port = 3000; -console.log(`Server is running on http://localhost:${port}`); - serve({ fetch: app.fetch, - port, + port: 3000, +}, (info) => { + console.log(`Server is running on http://localhost:${info.port}`) });