Add /api/health and /api/tasks route handlers
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { createTask, listTasks } from '@/lib/tasks';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json(await listTasks());
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.json().catch(() => null);
|
||||
const title = typeof body?.title === 'string' ? body.title.trim() : '';
|
||||
if (!title) return NextResponse.json({ error: 'title is required' }, { status: 400 });
|
||||
return NextResponse.json(await createTask(title, body.assignee), { status: 201 });
|
||||
}
|
||||
Reference in New Issue
Block a user