From 0b1360ce5cbac0d3e26d23bda61c3ada5c944226 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 2 Apr 2024 15:50:27 +0200 Subject: [PATCH] perf: register api endpoint before static host --- package.json | 2 +- src/server.ts | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2e90186..c6a51e5 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dev": "nuxi dev", "prepare": "nuxi prepare", "start": "node bin.mjs", - "prepublishOnly": "pnpm build", + "prepack": "pnpm build", "lint": "nuxi prepare && eslint .", "typecheck": "vue-tsc --noEmit" }, diff --git a/src/server.ts b/src/server.ts index ab5a600..b90100d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -7,13 +7,6 @@ import { distDir } from './dirs' export async function createHostServer() { const app = connect() - console.log() - - app.use(sirv(distDir, { - dev: true, - single: true, - })) - const ws = await createWsServer() app.use('/api/payload.json', async (_req, res) => { @@ -21,7 +14,10 @@ export async function createHostServer() { res.end(JSON.stringify(await ws.getData())) }) - const server = createServer(app) + app.use(sirv(distDir, { + dev: true, + single: true, + })) - return server + return createServer(app) }