Merge branch 'worktree-agent-a86c0a6d' into Develop

# Conflicts:
#	.planning/REQUIREMENTS.md
#	.planning/STATE.md
#	src/db/schema.ts
#	src/db/seed.ts
#	src/server/index.ts
#	src/server/routes/setups.ts
#	src/server/services/category.service.ts
#	src/server/services/setup.service.ts
#	src/shared/schemas.ts
#	src/shared/types.ts
This commit is contained in:
2026-04-05 13:13:34 +02:00
16 changed files with 993 additions and 225 deletions

View File

@@ -9,6 +9,8 @@ import {
deleteApiKey,
listApiKeys,
} from "../services/auth.service.ts";
import { updateProfile } from "../services/profile.service.ts";
import { updateProfileSchema } from "../../shared/schemas.ts";
type Env = { Variables: { db?: any; userId?: number } };
@@ -69,4 +71,20 @@ app.delete("/keys/:id", requireAuth, async (c) => {
return c.json({ ok: true });
});
// ── Profile Update (protected) ──────────────────────────────────────
app.put(
"/profile",
requireAuth,
zValidator("json", updateProfileSchema),
async (c) => {
const db = c.get("db");
const userId = c.get("userId")!;
const data = c.req.valid("json");
const updated = await updateProfile(db, userId, data);
if (!updated) return c.json({ error: "User not found" }, 404);
return c.json(updated);
},
);
export const authRoutes = app;

View File

@@ -0,0 +1,21 @@
import { Hono } from "hono";
import { parseId } from "../lib/params.ts";
import { getPublicProfile } from "../services/profile.service.ts";
type Env = { Variables: { db?: any; userId?: number } };
const app = new Hono<Env>();
// GET /:id/profile — Public profile (no auth required)
app.get("/:id/profile", async (c) => {
const db = c.get("db");
const id = parseId(c.req.param("id"));
if (!id) return c.json({ error: "Invalid user ID" }, 400);
const profile = await getPublicProfile(db, id);
if (!profile) return c.json({ error: "User not found" }, 404);
return c.json(profile);
});
export { app as profileRoutes };

View File

@@ -8,6 +8,7 @@ import {
} from "../../shared/schemas.ts";
import { parseId } from "../lib/params.ts";
import { withImageUrls } from "../services/storage.service.ts";
import { getPublicSetupWithItems } from "../services/profile.service.ts";
import {
createSetup,
deleteSetup,
@@ -40,6 +41,16 @@ app.post("/", zValidator("json", createSetupSchema), async (c) => {
return c.json(setup, 201);
});
// Public setup view (no auth required — skipped in index.ts middleware)
app.get("/:id/public", async (c) => {
const db = c.get("db");
const id = parseId(c.req.param("id"));
if (!id) return c.json({ error: "Invalid setup ID" }, 400);
const setup = await getPublicSetupWithItems(db, id);
if (!setup) return c.json({ error: "Setup not found" }, 404);
return c.json(setup);
});
app.get("/:id", async (c) => {
const db = c.get("db");
const userId = c.get("userId")!;