fix: add explicit DB context middleware for all API routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { Hono } from "hono";
|
||||
import { db as prodDb } from "../../db/index.ts";
|
||||
import { settings } from "../../db/schema.ts";
|
||||
|
||||
type Env = { Variables: { db?: any } };
|
||||
@@ -8,7 +7,7 @@ type Env = { Variables: { db?: any } };
|
||||
const app = new Hono<Env>();
|
||||
|
||||
app.get("/:key", (c) => {
|
||||
const database = c.get("db") ?? prodDb;
|
||||
const database = c.get("db");
|
||||
const key = c.req.param("key");
|
||||
const row = database
|
||||
.select()
|
||||
@@ -20,7 +19,7 @@ app.get("/:key", (c) => {
|
||||
});
|
||||
|
||||
app.put("/:key", async (c) => {
|
||||
const database = c.get("db") ?? prodDb;
|
||||
const database = c.get("db");
|
||||
const key = c.req.param("key");
|
||||
const body = await c.req.json<{ value: string }>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user