From de3f10b3ee3ea745b788c132288adf2c11e8b155 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Wed, 16 Nov 2022 19:28:29 +0100 Subject: [PATCH] Working ts --- package.json | 6 +++--- server.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b7f1e69..2c50cba 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "main": "index.js", "type": "module", "scripts": { - "dev": "run-s build:server serve:dev", - "build": "run-s build:client build:ssr build:server", - "build:server": "esbuild server.ts --bundle --platform=node --format=esm --external:./node_modules/* --outdir=dist/server", "build:client": "vite build --outDir dist/entry-client", "build:ssr": "vite build --ssr client/entry-server.tsx --outDir dist/entry-server", + "build:server": "esbuild server.ts --bundle --platform=node --format=esm --external:./node_modules/* --outdir=dist/server", + "build": "run-s build:client build:ssr build:server", "serve:dev": "MODE=development node dist/server/server.js", + "dev": "run-s build:server serve:dev", "serve": "node dist/server/server.js" }, "license": "MIT", diff --git a/server.ts b/server.ts index 74823a3..a59ab7d 100644 --- a/server.ts +++ b/server.ts @@ -1,7 +1,7 @@ import path from 'path' import fs from 'fs/promises' -import express from 'express' +import express, { Handler, Router } from 'express' import morgan from 'morgan' import { createServer as createViteServer } from 'vite' @@ -21,7 +21,7 @@ if (config.isDevelopment) { console.log(`[Config] PORT = ${config.port}`) } -function mountIndexHtmlRoutes(r, serveIndexHtml) { +function mountIndexHtmlRoutes(r: Router, serveIndexHtml: Handler) { for (const route of HTML_ROUTES) { console.log(`[Server] Mounted index html for "${route}"`) r.get(route, serveIndexHtml)