Closed github-actions[bot] closed 7 months ago
https://github.com/Superalexandre/portfolio/blob/06093250d5fda272f34c011e35b6009e9bda8ce1/server.ts#L33
// import { serve } from "@hono/node-server" import { serveStatic } from "@hono/node-server/serve-static" import { AppLoadContext, ServerBuild } from "@remix-run/node" import { Hono } from "hono" import { compress } from "hono/compress" import { remix } from "remix-hono/handler" // import { Server } from "socket.io" import "dotenv/config" // import { v4 as uuid } from "uuid" // import reply from "./ai/ai.js" // import AIMessage from "./types/AIMessage" const isDev = ["test", "development"].includes(process.env.NODE_ENV) const app = new Hono() async function getDevBuild() { if (!isDev) return const viteDevServer = await import("vite").then((vite) => vite.createServer({ server: { middlewareMode: true } })) const module = await viteDevServer.ssrLoadModule(`virtual:remix/server-build?t=${Date.now()}`) return module } app.use(async (c, next) => { // eslint-disable-next-line import/no-unresolved const build = (isDev ? await getDevBuild() : await import("./build/index.js")) as unknown as ServerBuild return remix({ build: () => build, mode: process.env.NODE_ENV as "development" | "production", getLoadContext: () => { return { appVersion: isDev ? build.assets.version : "dev" } satisfies AppLoadContext } })(c, next) }) app.use(compress()) app.use("/*", serveStatic({ root: "./build/client" })) // app.use("/build/*", serveStatic({ root: "./public/build" })) app.use("/assets/*", serveStatic({ root: "./build/client" })) /* if (!isDev) { serve({ ...app, port: Number(process.env.PORT) || 3000 }, (info) => { console.log(`Server listening on http://localhost:${info.port} in ${process.env.NODE_ENV} mode.`) }) } */ /* const io = new Server(server, { path: "/api/ws" })
Closed in e0bbb4ef4539daa00e0a9f42f34e528278a38dd4
https://github.com/Superalexandre/portfolio/blob/06093250d5fda272f34c011e35b6009e9bda8ce1/server.ts#L33