Files
api/apps/api/src/routes/dev.ts
T
Chris Farhood 56100b6811 fix: resolve CI failures from stale lockfile and incorrect import paths
- Regenerated pnpm-lock.yaml to remove stale workspace references (@groombook/db, @groombook/types) from monorepo extraction
- Fixed all relative imports to include .js extensions required by NodeNext module resolution
- Corrected db import paths throughout codebase (./db → ./db/index.js or ../db/index.js based on file location)
- Removed unused pickN helper function from db/seed.ts
- Fixed lint errors: changed const startTime to let where reassignment occurs

This unblocks CI which was failing at the "Install dependencies" step.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-11 01:14:25 +00:00

47 lines
1.2 KiB
TypeScript

import { Hono } from "hono";
import { getDb, staff, clients, eq, sql } from "../db/index.js";
const devRouter = new Hono();
// GET /api/dev/config — tells the frontend whether auth is disabled
devRouter.get("/config", (c) => {
return c.json({ authDisabled: process.env.AUTH_DISABLED === "true" });
});
// GET /api/dev/users — list staff and clients for the login selector
// Only available when AUTH_DISABLED=true
devRouter.get("/users", async (c) => {
if (process.env.AUTH_DISABLED !== "true") {
return c.json({ error: "Not available when auth is enabled" }, 403);
}
const db = getDb();
const staffList = await db
.select({
id: staff.id,
userId: staff.userId,
name: staff.name,
email: staff.email,
role: staff.role,
})
.from(staff)
.where(eq(staff.active, true))
.orderBy(staff.name);
const clientList = await db
.select({
id: clients.id,
name: clients.name,
email: clients.email,
petCount: sql<number>`(SELECT count(*) FROM pets WHERE pets.client_id = ${clients.id})`.as("pet_count"),
})
.from(clients)
.orderBy(clients.name)
.limit(20);
return c.json({ staff: staffList, clients: clientList });
});
export { devRouter };