mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-23 15:14:23 +00:00
23 lines
No EOL
769 B
TypeScript
23 lines
No EOL
769 B
TypeScript
import { database } from "../../../utils/prismaClient";
|
|
import { NextApiRequest, NextApiResponse } from "next";
|
|
import { ApiResult } from "../../../types/api";
|
|
import { restInPeace } from "../../../utils/restInPeace";
|
|
import { handleInterrupts } from "../../../utils/interrupt";
|
|
import { authorizeUser } from "../../../utils/authorizeUser";
|
|
import { Event } from "@prisma/client";
|
|
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResult<Event | Event[]>>) {
|
|
handleInterrupts(res, async () => {
|
|
const user = await authorizeUser(req)
|
|
|
|
const where = {
|
|
creatorId: user.id
|
|
}
|
|
|
|
await restInPeace(req, res, {
|
|
model: database.event,
|
|
list: {where}
|
|
})
|
|
})
|
|
} |