-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathremove-contract-subscription.ts
More file actions
55 lines (49 loc) · 1.51 KB
/
Copy pathremove-contract-subscription.ts
File metadata and controls
55 lines (49 loc) · 1.51 KB
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
import { type Static, Type } from "@sinclair/typebox";
import type { FastifyInstance } from "fastify";
import { StatusCodes } from "http-status-codes";
import { deleteContractSubscription } from "../../../../shared/db/contract-subscriptions/delete-contract-subscription";
import { standardResponseSchema } from "../../../schemas/shared-api-schemas";
const bodySchema = Type.Object({
contractSubscriptionId: Type.String({
description: "The ID for an existing contract subscription.",
}),
});
const responseSchema = Type.Object({
result: Type.Object({
status: Type.String(),
}),
});
responseSchema.example = {
result: {
status: "success",
},
};
export async function removeContractSubscription(fastify: FastifyInstance) {
fastify.route<{
Body: Static<typeof bodySchema>;
Reply: Static<typeof responseSchema>;
}>({
method: "POST",
url: "/contract-subscriptions/remove",
schema: {
summary: "Remove contract subscription",
description: "Remove an existing contract subscription",
tags: ["Contract-Subscriptions"],
operationId: "removeContractSubscription",
body: bodySchema,
response: {
...standardResponseSchema,
[StatusCodes.OK]: responseSchema,
},
},
handler: async (request, reply) => {
const { contractSubscriptionId } = request.body;
await deleteContractSubscription(contractSubscriptionId);
reply.status(StatusCodes.OK).send({
result: {
status: "success",
},
});
},
});
}