feat(F-163): completed feature

This commit is contained in:
chattie
2026-08-22 18:33:24 +02:00
parent 08af6caf50
commit 5d90dd32de
19 changed files with 403 additions and 37 deletions

View File

@@ -23,6 +23,9 @@ export interface PosRouteDeps {
}
const idParamSchema = z.object({ id: z.string().uuid() });
// Zod's strict UUID parser rejects the RFC nil UUID used by the seeded default
// store. Store references accept the canonical UUID shape, including nil.
const storeIdSchema = z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps) {
const { pool, authenticate } = deps;
@@ -174,7 +177,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
const user = await authenticate(request);
requireRole(user, 'admin');
const body = parseJson(
z.object({ storeId: z.string().uuid(), name: z.string().min(1).max(100) }),
z.object({ storeId: storeIdSchema, name: z.string().min(1).max(100) }),
request.body ?? {},
);
// Generate a short binding code (8 hex chars)