16 lines
563 B
TypeScript
16 lines
563 B
TypeScript
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 });
|
|
}
|