mirror of
https://github.com/khairul169/home-lab.git
synced 2025-04-28 16:49:36 +07:00
26 lines
732 B
TypeScript
26 lines
732 B
TypeScript
import "dotenv/config";
|
|
import { Hono } from "hono";
|
|
import { cors } from "hono/cors";
|
|
import { HTTPException } from "hono/http-exception";
|
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
import { serve } from "@hono/node-server";
|
|
import routes from "./routes/_routes";
|
|
import createWsServer from "./websocket";
|
|
|
|
const app = new Hono()
|
|
.use(cors())
|
|
.use("*", serveStatic({ root: "./public" }))
|
|
.route("/", routes)
|
|
.onError((err, c) => {
|
|
if (err instanceof HTTPException) {
|
|
return err.getResponse();
|
|
}
|
|
return c.json({ message: err.message }, 500);
|
|
});
|
|
|
|
const server = serve(app, (info) => {
|
|
console.log(`App listening on http://${info.address}:${info.port}`);
|
|
});
|
|
|
|
createWsServer(server);
|