1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-23 07:04:22 +00:00
festa/pages/api/events/mine.ts

50 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-05-31 14:46:06 +00:00
import { database } from "../../../utils/prismaClient";
import { NextApiRequest, NextApiResponse } from "next";
2022-06-11 03:08:49 +00:00
import { Event, Prisma } from "@prisma/client";
import { festaNoConfig } from "../../../utils/api/configurator";
import { festaBearerAuthRequired, FestaToken } from "../../../utils/api/authenticator";
import { festaAPI } from "../../../utils/api";
import { festaNoQuery } from "../../../utils/api/queryValidator";
2022-07-17 17:54:14 +00:00
import { festaNoBody } from "../../../utils/api/bodyValidator";
2022-06-11 03:08:49 +00:00
import { festaRESTGeneric } from "../../../utils/api/executor";
import { Response } from "../../../utils/api/throwables";
type Config = {}
type Auth = FestaToken
type Query = {}
type Body = {}
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
await festaAPI(req, res, {
configurator: festaNoConfig,
authenticator: festaBearerAuthRequired,
queryValidator: festaNoQuery,
bodyValidator: festaNoBody,
executor: festaRESTGeneric<Config, Auth, Query, Body, Event, Prisma.EventDelegate<any>, Prisma.EventFindManyArgs, Prisma.EventCreateArgs>({
delegate: database.event,
getListArgs: async ({ auth }) => {
return {
where: {
creatorId: auth.userId,
}
}
},
getCreateArgs: async ({ }) => {
throw Response.error({ status: 405, message: "This route cannot be used to create new events" })
},
}),
})
2022-06-11 03:08:49 +00:00
}