2022-05-31 14:35:13 +00:00
|
|
|
import { client } 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/apiAuth";
|
|
|
|
import { Event } from "@prisma/client";
|
|
|
|
|
|
|
|
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResult<Event | Event[]>>) {
|
|
|
|
handleInterrupts(res, async () => {
|
2022-05-31 14:39:30 +00:00
|
|
|
const user = await authorizeUser(req)
|
2022-05-31 14:35:13 +00:00
|
|
|
|
|
|
|
const where = {
|
|
|
|
creatorId: user.id
|
|
|
|
}
|
|
|
|
|
|
|
|
await restInPeace(req, res, {
|
|
|
|
model: client.event,
|
|
|
|
list: {where}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|