Skip to content

Commit fead04d

Browse files
committed
refactor: cleanup example & avoid mixing dependency
1 parent fd83258 commit fead04d

File tree

7 files changed

+31
-389
lines changed

7 files changed

+31
-389
lines changed

.github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ updates:
1919
dependency-type: "production"
2020
development-dependencies:
2121
dependency-type: "development"
22+
23+
- package-ecosystem: npm
24+
directory: /example/fastify
25+
schedule:
26+
interval: weekly
27+
ignore:
28+
- dependency-name: "*"

example/fastify/app.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
// Import Node.js Dependencies
2-
import { createHmac } from "crypto";
2+
import { createHmac } from "node:crypto";
33

44
// Import Third-party Dependencies
5-
import fastify, { FastifyRequest } from "fastify";
6-
7-
// Import Types
8-
import { FastifyInstance } from "fastify/types/instance";
5+
import fastify, { type FastifyRequest, type FastifyInstance } from "fastify";
96

107
// Import Internal Dependencies
11-
import { webhooksAPI } from "./feature/webhook";
8+
import { webhooksAPI } from "./feature/webhook.js";
129

1310
// CONSTANTS
1411
const kSecret = "foo";
1512

1613
export function buildServer(): FastifyInstance {
1714
const app = fastify({
1815
logger: {
19-
level: "info",
20-
transport: {
21-
target: "pino-pretty"
22-
}
16+
level: "info"
2317
}
2418
});
2519

example/fastify/feature/webhook.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Import Internal Dependencies
2-
import * as MyEvents from "../../../src/index";
3-
4-
// Import types
5-
import {
1+
// Import Third-party Dependencies
2+
import type {
63
FastifyRequest,
74
FastifyReply,
85
FastifyInstance
96
} from "fastify";
107

8+
// Import Internal Dependencies
9+
import * as MyEvents from "../../../src/index.js";
10+
1111
export async function webhooksAPI(server: FastifyInstance) {
1212
server.post("/anyEvents", getAnyWebhooks);
1313
server.post("/connector", getConnectorWebhooks);
@@ -21,7 +21,10 @@ type GetAnyWebhooksRequest = FastifyRequest<{
2121
Body: MyEvents.WebhooksResponse;
2222
}>;
2323

24-
async function getAnyWebhooks(req: GetAnyWebhooksRequest, reply: FastifyReply) {
24+
async function getAnyWebhooks(
25+
request: GetAnyWebhooksRequest,
26+
reply: FastifyReply
27+
) {
2528
// Do some code
2629
}
2730

@@ -33,6 +36,9 @@ type GetConnectorWebhooksRequest = FastifyRequest<{
3336
Body: MyEvents.WebhooksResponse<["connector"]>;
3437
}>;
3538

36-
async function getConnectorWebhooks(req: GetConnectorWebhooksRequest, reply: FastifyReply) {
39+
async function getConnectorWebhooks(
40+
request: GetConnectorWebhooksRequest,
41+
reply: FastifyReply
42+
) {
3743
// Do some code
3844
}

example/fastify/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "webhook-api-example",
3+
"dependencies": {
4+
"fastify": "^4.3.0"
5+
}
6+
}

0 commit comments

Comments
 (0)