@t402/fastify 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +45 -43
  2. package/package.json +15 -15
package/README.md CHANGED
@@ -11,42 +11,44 @@ npm install @t402/fastify
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import Fastify from "fastify";
15
- import { paymentMiddleware, t402ResourceServer } from "@t402/fastify";
16
- import { ExactEvmScheme } from "@t402/evm/exact/server";
17
- import { HTTPFacilitatorClient } from "@t402/core/server";
14
+ import Fastify from 'fastify'
15
+ import { paymentMiddleware, t402ResourceServer } from '@t402/fastify'
16
+ import { ExactEvmScheme } from '@t402/evm/exact/server'
17
+ import { HTTPFacilitatorClient } from '@t402/core/server'
18
18
 
19
- const app = Fastify();
19
+ const app = Fastify()
20
20
 
21
- const facilitatorClient = new HTTPFacilitatorClient({ url: "https://facilitator.t402.io" });
22
- const resourceServer = new t402ResourceServer(facilitatorClient)
23
- .register("eip155:84532", new ExactEvmScheme());
21
+ const facilitatorClient = new HTTPFacilitatorClient({ url: 'https://facilitator.t402.io' })
22
+ const resourceServer = new t402ResourceServer(facilitatorClient).register(
23
+ 'eip155:84532',
24
+ new ExactEvmScheme(),
25
+ )
24
26
 
25
27
  // Apply the payment middleware with your configuration
26
28
  app.addHook(
27
- "onRequest",
29
+ 'onRequest',
28
30
  paymentMiddleware(
29
31
  {
30
- "GET /protected-route": {
32
+ 'GET /protected-route': {
31
33
  accepts: {
32
- scheme: "exact",
33
- price: "$0.10",
34
- network: "eip155:84532",
35
- payTo: "0xYourAddress",
34
+ scheme: 'exact',
35
+ price: '$0.10',
36
+ network: 'eip155:84532',
37
+ payTo: '0xYourAddress',
36
38
  },
37
- description: "Access to premium content",
39
+ description: 'Access to premium content',
38
40
  },
39
41
  },
40
42
  resourceServer,
41
43
  ),
42
- );
44
+ )
43
45
 
44
46
  // Implement your protected route
45
- app.get("/protected-route", async (request, reply) => {
46
- return { message: "This content is behind a paywall" };
47
- });
47
+ app.get('/protected-route', async (request, reply) => {
48
+ return { message: 'This content is behind a paywall' }
49
+ })
48
50
 
49
- app.listen({ port: 3000 });
51
+ app.listen({ port: 3000 })
50
52
  ```
51
53
 
52
54
  ## Configuration
@@ -75,49 +77,49 @@ paymentMiddleware(
75
77
 
76
78
  ```typescript
77
79
  const routes: RoutesConfig = {
78
- "GET /api/protected": {
80
+ 'GET /api/protected': {
79
81
  accepts: {
80
- scheme: "exact",
81
- price: "$0.10",
82
- network: "eip155:84532",
83
- payTo: "0xYourAddress",
82
+ scheme: 'exact',
83
+ price: '$0.10',
84
+ network: 'eip155:84532',
85
+ payTo: '0xYourAddress',
84
86
  maxTimeoutSeconds: 60,
85
87
  },
86
- description: "Premium API access",
88
+ description: 'Premium API access',
87
89
  },
88
- };
90
+ }
89
91
  ```
90
92
 
91
93
  ## Multiple Payment Networks
92
94
 
93
95
  ```typescript
94
96
  app.addHook(
95
- "onRequest",
97
+ 'onRequest',
96
98
  paymentMiddleware(
97
99
  {
98
- "GET /api/data": {
100
+ 'GET /api/data': {
99
101
  accepts: [
100
102
  {
101
- scheme: "exact",
102
- price: "$0.10",
103
- network: "eip155:8453",
103
+ scheme: 'exact',
104
+ price: '$0.10',
105
+ network: 'eip155:8453',
104
106
  payTo: evmAddress,
105
107
  },
106
108
  {
107
- scheme: "exact",
108
- price: "$0.10",
109
- network: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
109
+ scheme: 'exact',
110
+ price: '$0.10',
111
+ network: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
110
112
  payTo: svmAddress,
111
113
  },
112
114
  ],
113
- description: "Data API access",
115
+ description: 'Data API access',
114
116
  },
115
117
  },
116
118
  new t402ResourceServer(facilitatorClient)
117
- .register("eip155:8453", new ExactEvmScheme())
118
- .register("solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", new ExactSvmScheme()),
119
+ .register('eip155:8453', new ExactEvmScheme())
120
+ .register('solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', new ExactSvmScheme()),
119
121
  ),
120
- );
122
+ )
121
123
  ```
122
124
 
123
125
  ## Paywall Configuration
@@ -132,12 +134,12 @@ pnpm add @t402/paywall
132
134
 
133
135
  ```typescript
134
136
  const paywallConfig: PaywallConfig = {
135
- appName: "Your App Name",
136
- appLogo: "/path/to/logo.svg",
137
+ appName: 'Your App Name',
138
+ appLogo: '/path/to/logo.svg',
137
139
  testnet: true,
138
- };
140
+ }
139
141
 
140
- app.addHook("onRequest", paymentMiddleware(routes, resourceServer, paywallConfig));
142
+ app.addHook('onRequest', paymentMiddleware(routes, resourceServer, paywallConfig))
141
143
  ```
142
144
 
143
145
  ## Peer Dependencies
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t402/fastify",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -18,32 +18,32 @@
18
18
  "repository": "https://github.com/t402-io/t402",
19
19
  "description": "t402 Payment Protocol middleware for Fastify",
20
20
  "devDependencies": {
21
- "@eslint/js": "^9.24.0",
22
- "@types/node": "^22.13.4",
23
- "@typescript-eslint/eslint-plugin": "^8.29.1",
24
- "@typescript-eslint/parser": "^8.29.1",
21
+ "@eslint/js": "^9.39.2",
22
+ "@types/node": "^25.2.2",
23
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
24
+ "@typescript-eslint/parser": "^8.55.0",
25
25
  "eslint": "^9.24.0",
26
26
  "eslint-plugin-import": "^2.31.0",
27
- "eslint-plugin-jsdoc": "^50.6.9",
28
- "eslint-plugin-prettier": "^5.2.6",
29
- "fastify": "^5.7.0",
27
+ "eslint-plugin-jsdoc": "^62.5.4",
28
+ "eslint-plugin-prettier": "^5.5.5",
29
+ "fastify": "^5.7.3",
30
30
  "glob": "^13.0.0",
31
- "prettier": "3.5.2",
32
- "tsup": "^8.4.0",
31
+ "prettier": "3.8.1",
32
+ "tsup": "^8.5.1",
33
33
  "tsx": "^4.21.0",
34
- "typescript": "^5.7.3",
34
+ "typescript": "^5.9.3",
35
35
  "vite": "^7.3.1",
36
- "vite-tsconfig-paths": "^5.1.4",
36
+ "vite-tsconfig-paths": "^6.1.0",
37
37
  "vitest": "^3.2.4"
38
38
  },
39
39
  "dependencies": {
40
40
  "zod": "^3.24.2",
41
- "@t402/extensions": "2.3.1",
42
- "@t402/core": "2.3.1"
41
+ "@t402/extensions": "2.5.0",
42
+ "@t402/core": "2.5.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "fastify": "^4.0.0 || ^5.0.0",
46
- "@t402/paywall": "2.3.1"
46
+ "@t402/paywall": "2.5.0"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@t402/paywall": {