Initial commit: Cat Sitting Planner with PWA, SQLite, and Webhook Notifications
This commit is contained in:
27
app/api/plan/route.ts
Normal file
27
app/api/plan/route.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import prisma from '@/lib/prisma';
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
const body = await req.json();
|
||||
const { startDate, endDate, password, instructions } = body;
|
||||
|
||||
if (!startDate || !endDate || !password) {
|
||||
return NextResponse.json({ error: 'Missing required fields' }, { status: 400 });
|
||||
}
|
||||
|
||||
const plan = await prisma.plan.create({
|
||||
data: {
|
||||
startDate: new Date(startDate),
|
||||
endDate: new Date(endDate),
|
||||
password,
|
||||
instructions,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ planId: plan.id });
|
||||
} catch (error) {
|
||||
console.error('Error creating plan:', error);
|
||||
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user