← back to Norma Platform
app/api/action-center/[id]/route.ts
14 lines
import { NextRequest, NextResponse } from 'next/server';
import { participate, publicAction } from '@/lib/campaigns/intake';
import { body, failure } from '@/lib/campaigns/validation';
export const dynamic = 'force-dynamic';
type Context = {params: Promise<{id:string}>};
export async function GET(request: NextRequest, context: Context) {
try { return NextResponse.json(await publicAction(request,(await context.params).id),{headers:{'Cache-Control':'no-store'}}); }
catch(error) { return failure(error); }
}
export async function POST(request: NextRequest, context: Context) {
try { return NextResponse.json(await participate(request,(await context.params).id,await body(request)),{status:202,headers:{'Cache-Control':'no-store'}}); }
catch(error) { return failure(error); }
}