26 lines
681 B
TypeScript
26 lines
681 B
TypeScript
import { parseRequest } from '@/lib/request';
|
|
import { json, unauthorized } from '@/lib/response';
|
|
import { canViewWebsiteSection } from '@/permissions';
|
|
import { getEventDataById } from '@/queries/sql/events/getEventDataById';
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ websiteId: string; eventId: string }> },
|
|
) {
|
|
const { auth, error } = await parseRequest(request);
|
|
|
|
if (error) {
|
|
return error();
|
|
}
|
|
|
|
const { websiteId, eventId } = await params;
|
|
|
|
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
|
|
return unauthorized();
|
|
}
|
|
|
|
const data = await getEventDataById(websiteId, eventId);
|
|
|
|
return json(data);
|
|
}
|