Files
wedding-planner/app/api/events/route.ts
2025-06-23 16:38:52 -04:00

21 lines
654 B
TypeScript

import { getServerSession } from 'next-auth'
import { authOptions } from '@/app/api/auth/[...nextauth]/route'
import { mutations } from '@/lib/mutations';
import { NextRequest, NextResponse } from 'next/server';
export async function POST(req: NextRequest) {
const session = await getServerSession(authOptions)
if (!session?.user) return new NextResponse('Unauthorized', { status: 401 });
const body = await req.json();
const { name, date, location } = body;
const event = await mutations.createEvent({
name,
date,
location,
creatorId: session.user.id,
});
return NextResponse.json(event)
}