@superfunctions/http-fastify 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @superfunctions/http @superfunctions/http-fastify fastify
13
13
  ```typescript
14
14
  import Fastify from 'fastify';
15
15
  import { createRouter } from '@superfunctions/http';
16
- import { toFastifyPlugin } from '@superfunctions/http-fastify';
16
+ import { toFastify } from '@superfunctions/http-fastify';
17
17
 
18
18
  // Define your router (framework-agnostic)
19
19
  const apiRouter = createRouter({
@@ -30,13 +30,13 @@ const apiRouter = createRouter({
30
30
 
31
31
  // Use with Fastify
32
32
  const fastify = Fastify();
33
- await fastify.register(toFastifyPlugin(apiRouter), { prefix: '/api' });
33
+ await fastify.register(toFastify(apiRouter), { prefix: '/api' });
34
34
  await fastify.listen({ port: 3000 });
35
35
  ```
36
36
 
37
37
  ## API
38
38
 
39
- ### `toFastifyPlugin(router)`
39
+ ### `toFastify(router)`
40
40
 
41
41
  Converts a `@superfunctions/http` router to a Fastify plugin.
42
42
 
@@ -47,9 +47,9 @@ Converts a `@superfunctions/http` router to a Fastify plugin.
47
47
 
48
48
  **Example:**
49
49
  ```typescript
50
- import { toFastifyPlugin } from '@superfunctions/http-fastify';
50
+ import { toFastify } from '@superfunctions/http-fastify';
51
51
 
52
- await fastify.register(toFastifyPlugin(myRouter), {
52
+ await fastify.register(toFastify(myRouter), {
53
53
  prefix: '/api'
54
54
  });
55
55
  ```
@@ -61,12 +61,12 @@ await fastify.register(toFastifyPlugin(myRouter), {
61
61
 
62
62
  ```typescript
63
63
  import Fastify from 'fastify';
64
- import { toFastifyPlugin } from '@superfunctions/http-fastify';
64
+ import { toFastify } from '@superfunctions/http-fastify';
65
65
 
66
66
  const fastify = Fastify();
67
67
 
68
68
  // Register with prefix
69
- await fastify.register(toFastifyPlugin(apiRouter), {
69
+ await fastify.register(toFastify(apiRouter), {
70
70
  prefix: '/api/v1'
71
71
  });
72
72
 
@@ -78,7 +78,7 @@ await fastify.listen({ port: 3000 });
78
78
 
79
79
  ```typescript
80
80
  import { createRouter } from '@superfunctions/http';
81
- import { toFastifyPlugin } from '@superfunctions/http-fastify';
81
+ import { toFastify } from '@superfunctions/http-fastify';
82
82
 
83
83
  const router = createRouter({
84
84
  middleware: [
@@ -100,7 +100,7 @@ const router = createRouter({
100
100
  ],
101
101
  });
102
102
 
103
- await fastify.register(toFastifyPlugin(router), { prefix: '/api' });
103
+ await fastify.register(toFastify(router), { prefix: '/api' });
104
104
  ```
105
105
 
106
106
  ### With Custom Context
@@ -124,7 +124,7 @@ const router = createRouter<AppContext>({
124
124
  ],
125
125
  });
126
126
 
127
- await fastify.register(toFastifyPlugin(router), { prefix: '/api' });
127
+ await fastify.register(toFastify(router), { prefix: '/api' });
128
128
  ```
129
129
 
130
130
  ### Multiple Routers
@@ -133,8 +133,8 @@ await fastify.register(toFastifyPlugin(router), { prefix: '/api' });
133
133
  const usersRouter = createRouter({ routes: [/* user routes */] });
134
134
  const postsRouter = createRouter({ routes: [/* post routes */] });
135
135
 
136
- await fastify.register(toFastifyPlugin(usersRouter), { prefix: '/api/users' });
137
- await fastify.register(toFastifyPlugin(postsRouter), { prefix: '/api/posts' });
136
+ await fastify.register(toFastify(usersRouter), { prefix: '/api/users' });
137
+ await fastify.register(toFastify(postsRouter), { prefix: '/api/posts' });
138
138
  ```
139
139
 
140
140
  ### With Fastify Decorators
@@ -144,7 +144,7 @@ You can combine with other Fastify plugins:
144
144
  ```typescript
145
145
  import Fastify from 'fastify';
146
146
  import fastifyCors from '@fastify/cors';
147
- import { toFastifyPlugin } from '@superfunctions/http-fastify';
147
+ import { toFastify } from '@superfunctions/http-fastify';
148
148
 
149
149
  const fastify = Fastify();
150
150
 
@@ -154,7 +154,7 @@ await fastify.register(fastifyCors, {
154
154
  });
155
155
 
156
156
  // Register your router
157
- await fastify.register(toFastifyPlugin(apiRouter), { prefix: '/api' });
157
+ await fastify.register(toFastify(apiRouter), { prefix: '/api' });
158
158
 
159
159
  await fastify.listen({ port: 3000 });
160
160
  ```
@@ -167,10 +167,10 @@ The adapter returns a Fastify plugin that must be registered with `await fastify
167
167
 
168
168
  ```typescript
169
169
  // ✅ Correct - await registration
170
- await fastify.register(toFastifyPlugin(router));
170
+ await fastify.register(toFastify(router));
171
171
 
172
172
  // ❌ Incorrect - missing await
173
- fastify.register(toFastifyPlugin(router));
173
+ fastify.register(toFastify(router));
174
174
  ```
175
175
 
176
176
  ### Prefix Handling
@@ -185,7 +185,7 @@ const router = createRouter({
185
185
  });
186
186
 
187
187
  // Route accessible at: /api/hello
188
- await fastify.register(toFastifyPlugin(router), { prefix: '/api' });
188
+ await fastify.register(toFastify(router), { prefix: '/api' });
189
189
  ```
190
190
 
191
191
  ### JSON Serialization
@@ -222,7 +222,7 @@ import type { Router } from '@superfunctions/http';
222
222
  import type { FastifyPluginAsync } from 'fastify';
223
223
 
224
224
  const myRouter: Router = createRouter({ routes: [...] });
225
- const plugin: FastifyPluginAsync = toFastifyPlugin(myRouter);
225
+ const plugin: FastifyPluginAsync = toFastify(myRouter);
226
226
 
227
227
  await fastify.register(plugin, { prefix: '/api' });
228
228
  ```
package/dist/adapter.d.ts CHANGED
@@ -8,8 +8,8 @@ import type { FastifyPluginAsync } from 'fastify';
8
8
  *
9
9
  * Usage:
10
10
  * ```typescript
11
- * fastify.register(toFastifyPlugin(router), { prefix: '/api' });
11
+ * fastify.register(toFastify(router), { prefix: '/api' });
12
12
  * ```
13
13
  */
14
- export declare function toFastifyPlugin(router: Router): FastifyPluginAsync;
14
+ export declare function toFastify(router: Router): FastifyPluginAsync;
15
15
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAmB,kBAAkB,EAAgC,MAAM,SAAS,CAAC;AAEjG;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAmBlE"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAmB,kBAAkB,EAAgC,MAAM,SAAS,CAAC;AAEjG;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAmB5D"}
package/dist/adapter.js CHANGED
@@ -6,10 +6,10 @@
6
6
  *
7
7
  * Usage:
8
8
  * ```typescript
9
- * fastify.register(toFastifyPlugin(router), { prefix: '/api' });
9
+ * fastify.register(toFastify(router), { prefix: '/api' });
10
10
  * ```
11
11
  */
12
- export function toFastifyPlugin(router) {
12
+ export function toFastify(router) {
13
13
  const plugin = async (fastify, opts) => {
14
14
  const prefix = opts.prefix || '';
15
15
  // Catch all route that delegates to the router
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,MAAM,GAAuB,KAAK,EAAE,OAAwB,EAAE,IAAS,EAAE,EAAE;QAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAEjC,+CAA+C;QAC/C,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAuB,EAAE,KAAmB,EAAE,EAAE;YACvE,kDAAkD;YAClD,8DAA8D;YAC9D,MAAM,UAAU,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAE9D,kDAAkD;YAClD,MAAM,WAAW,GAAG,MAAM,MAA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ify adapter
3
3
  */
4
- export { toFastifyPlugin } from './adapter.js';
4
+ export { toFastify } from './adapter.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * @superfunctions/http-fastify - Fastify adapter
3
3
  */
4
- export { toFastifyPlugin } from './adapter.js';
4
+ export { toFastify } from './adapter.js';
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfunctions/http-fastify",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Fastify adapter for @superfunctions/http",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",