feat(14-04): convert auth, OAuth, settings routes and auth middleware to async/await

- Add await before all service calls in auth, OAuth routes
- Convert settings.ts direct DB calls: remove .get()/.run(), use await + destructuring
- Auth middleware: await getUserCount, getSession, refreshSession
- Fix formatting in threads.ts for biome compliance
- All files pass lint
This commit is contained in:
2026-04-04 12:43:29 +02:00
parent 5edcc660e4
commit 22aaed76f2
5 changed files with 45 additions and 45 deletions

View File

@@ -6,14 +6,13 @@ type Env = { Variables: { db?: any } };
const app = new Hono<Env>();
app.get("/:key", (c) => {
app.get("/:key", async (c) => {
const database = c.get("db");
const key = c.req.param("key");
const row = database
const [row] = await database
.select()
.from(settings)
.where(eq(settings.key, key))
.get();
.where(eq(settings.key, key));
if (!row) return c.json({ error: "Setting not found" }, 404);
return c.json(row);
});
@@ -27,17 +26,15 @@ app.put("/:key", async (c) => {
return c.json({ error: "value is required" }, 400);
}
database
await database
.insert(settings)
.values({ key, value: body.value })
.onConflictDoUpdate({ target: settings.key, set: { value: body.value } })
.run();
.onConflictDoUpdate({ target: settings.key, set: { value: body.value } });
const row = database
const [row] = await database
.select()
.from(settings)
.where(eq(settings.key, key))
.get();
.where(eq(settings.key, key));
return c.json(row);
});