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
This commit is contained in:
Chandler Copeland
2026-03-19 21:36:21 -06:00
parent c830951afe
commit e0f180c3d8

View File

@@ -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);
}