summaryrefslogtreecommitdiff
path: root/cgithub/src
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-09-18 07:42:53 +0100
committerJoe Mou <dev@mou.fo>2026-09-18 08:11:33 +0100
commit363e8db444d9aade0fcca2bd3171653b7dab01d8 (patch)
tree64ef8ee4dc22ddb5313c6599e8e32754bb492991 /cgithub/src
parent9659525bf2387af6deab9d401784b94b1f44d395 (diff)
Run cgithub locally on elmotest
Diffstat (limited to 'cgithub/src')
-rw-r--r--cgithub/src/index.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/cgithub/src/index.ts b/cgithub/src/index.ts
new file mode 100644
index 0000000..79f09d9
--- /dev/null
+++ b/cgithub/src/index.ts
@@ -0,0 +1,25 @@
+import { createAdaptorServer, serve } from "@hono/node-server";
+import { serveStatic } from "@hono/node-server/serve-static";
+import { Eta } from "eta";
+import { Hono } from "hono";
+import path from "node:path";
+import { createApp } from "./app.ts";
+
+const root = path.join(import.meta.dirname, "..");
+const eta = new Eta({ views: path.join(root, "views") });
+
+const app = new Hono();
+app.use("/static/*", serveStatic({ root: path.join(root, "public") }));
+app.route("/", createApp(eta));
+
+if (process.env.LISTEN_FDS === "1") {
+ const server = createAdaptorServer(app);
+ server.listen({ fd: 3 }, () => {
+ console.log("Server running via systemd socket activation");
+ });
+} else {
+ const port = parseInt(process.env.PORT || "3000", 10);
+ serve({ fetch: app.fetch, port }, (info) => {
+ console.log(`Server running on http://localhost:${info.port}`);
+ });
+}