From e0f180c3d8f9fdb82cec15f9a43d6aec819e2b2b Mon Sep 17 00:00:00 2001 From: Chandler Copeland Date: Thu, 19 Mar 2026 21:36:21 -0600 Subject: [PATCH] feat(04-02): create GET /api/forms-library authenticated template list - Queries form_templates ordered by name (asc) - Returns 401 for unauthenticated requests - Returns JSON array of { id, name, filename } for authenticated agents --- .../src/app/api/forms-library/route.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 teressa-copeland-homes/src/app/api/forms-library/route.ts diff --git a/teressa-copeland-homes/src/app/api/forms-library/route.ts b/teressa-copeland-homes/src/app/api/forms-library/route.ts new file mode 100644 index 0000000..0ce697b --- /dev/null +++ b/teressa-copeland-homes/src/app/api/forms-library/route.ts @@ -0,0 +1,16 @@ +import { auth } from '@/lib/auth'; +import { db } from '@/lib/db'; +import { formTemplates } from '@/lib/db/schema'; +import { asc } from 'drizzle-orm'; + +export async function GET() { + const session = await auth(); + if (!session) return new Response('Unauthorized', { status: 401 }); + + const forms = await db + .select({ id: formTemplates.id, name: formTemplates.name, filename: formTemplates.filename }) + .from(formTemplates) + .orderBy(asc(formTemplates.name)); + + return Response.json(forms); +}