[feat] Basic Hono+Drizzle Server

This commit is contained in:
2026-06-07 20:30:11 +08:00
Unverified
parent 4541f8dca6
commit 9e506c06fe
12 changed files with 961 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
import "dotenv/config";
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";
import { Hono } from "@hono/hono";
import { commonResponse } from "./utils/response.ts";
const client = createClient({
url: `file:${process.env.DATABASE_PATH!}`,
});
const db = drizzle(client);
const app = new Hono();
app.get("/", (c) => {
return commonResponse(c, true, 200, { "hint": "Hello! But nothing here." });
});
app.get("/ping", (c) => {
return commonResponse(c, true, 200, {});
});
Deno.serve(app.fetch);
const handleExit = () => {
console.log("Closing database connection...");
db.$client.close();
console.log("Disconnected.");
process.exit(0);
};
process.on("SIGINT", handleExit);
process.on("SIGTERM", handleExit);