-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook.ts
44 lines (38 loc) · 910 Bytes
/
webhook.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
// Import Third-party Dependencies
import type {
FastifyRequest,
FastifyReply,
FastifyInstance
} from "fastify";
// Import Internal Dependencies
import * as MyEvents from "../../../src/index.js";
export async function webhooksAPI(server: FastifyInstance) {
server.post("/anyEvents", getAnyWebhooks);
server.post("/connector", getConnectorWebhooks);
}
type GetAnyWebhooksRequest = FastifyRequest<{
Headers: {
date: string;
signature: string;
};
Body: MyEvents.WebhooksResponse;
}>;
async function getAnyWebhooks(
request: GetAnyWebhooksRequest,
reply: FastifyReply
) {
// Do some code
}
type GetConnectorWebhooksRequest = FastifyRequest<{
Headers: {
date: string;
signature: string;
};
Body: MyEvents.WebhooksResponse<["connector"]>;
}>;
async function getConnectorWebhooks(
request: GetConnectorWebhooksRequest,
reply: FastifyReply
) {
// Do some code
}