-
Notifications
You must be signed in to change notification settings - Fork 6.9k
/
_delete.ts
56 lines (52 loc) · 1.75 KB
/
_delete.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { selectedCalendarIdSchema } from "~/lib/validations/selected-calendar";
/**
* @swagger
* /selected-calendars/{userId}_{integration}_{externalId}:
* delete:
* operationId: removeSelectedCalendarById
* summary: Remove a selected calendar
* parameters:
* - in: query
* name: apiKey
* schema:
* type: string
* required: true
* description: Your API Key
* - in: path
* name: userId
* schema:
* type: integer
* required: true
* description: userId of the selected calendar to get
* - in: path
* name: externalId
* schema:
* type: integer
* required: true
* description: externalId of the selected-calendar to get
* - in: path
* name: integration
* schema:
* type: string
* required: true
* description: integration of the selected calendar to get
* tags:
* - selected-calendars
* responses:
* 201:
* description: OK, selected-calendar removed successfully
* 400:
* description: Bad request. SelectedCalendar id is invalid.
* 401:
* description: Authorization information is missing or invalid.
*/
export async function deleteHandler(req: NextApiRequest) {
const { query } = req;
const userId_integration_externalId = selectedCalendarIdSchema.parse(query);
await prisma.selectedCalendar.delete({ where: { userId_integration_externalId } });
return { message: `Selected Calendar with id: ${query.id} deleted successfully` };
}
export default defaultResponder(deleteHandler);