You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
744 B
TypeScript

import { serve } from "@hono/node-server";
import { serveStatic } from "@hono/node-server/serve-static";
import { type Context, Hono } from "hono";
import { env } from "hono/adapter";
import { compress } from "hono/compress";
import app from "./hono-entry.js";
const envs = env<{ NODE_ENV?: string; PORT?: string }>({
env: {},
} as unknown as Context<{
Bindings: { NODE_ENV?: string; PORT?: string };
}>);
const nodeApp = new Hono();
nodeApp.use(compress());
nodeApp.use(
"/*",
serveStatic({
root: "./dist/client/",
}),
);
nodeApp.route("/", app);
const port = envs.PORT ? Number.parseInt(envs.PORT, 10) : 3000;
console.log(`Server listening on http://localhost:${port}`);
serve({
fetch: nodeApp.fetch,
port: port,
});