@superfunctions/http-hono 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-hono hono
13
13
  ```typescript
14
14
  import { Hono } from 'hono';
15
15
  import { createRouter } from '@superfunctions/http';
16
- import { toHonoHandler } from '@superfunctions/http-hono';
16
+ import { toHono } from '@superfunctions/http-hono';
17
17
 
18
18
  // Define your router (framework-agnostic)
19
19
  const apiRouter = createRouter({
@@ -30,14 +30,14 @@ const apiRouter = createRouter({
30
30
 
31
31
  // Use with Hono
32
32
  const app = new Hono();
33
- app.route('/api', toHonoHandler(apiRouter));
33
+ app.route('/api', toHono(apiRouter));
34
34
 
35
35
  export default app;
36
36
  ```
37
37
 
38
38
  ## API
39
39
 
40
- ### `toHonoHandler(router)`
40
+ ### `toHono(router)`
41
41
 
42
42
  Converts a `@superfunctions/http` router to a Hono instance.
43
43
 
@@ -48,9 +48,9 @@ Converts a `@superfunctions/http` router to a Hono instance.
48
48
 
49
49
  **Example:**
50
50
  ```typescript
51
- import { toHonoHandler } from '@superfunctions/http-hono';
51
+ import { toHono } from '@superfunctions/http-hono';
52
52
 
53
- const honoApp = toHonoHandler(myRouter);
53
+ const honoApp = toHono(myRouter);
54
54
  app.route('/api', honoApp);
55
55
  ```
56
56
 
@@ -61,7 +61,7 @@ app.route('/api', honoApp);
61
61
 
62
62
  ```typescript
63
63
  import { createRouter } from '@superfunctions/http';
64
- import { toHonoHandler } from '@superfunctions/http-hono';
64
+ import { toHono } from '@superfunctions/http-hono';
65
65
 
66
66
  const router = createRouter({
67
67
  middleware: [
@@ -84,7 +84,7 @@ const router = createRouter({
84
84
  });
85
85
 
86
86
  const app = new Hono();
87
- app.route('/api', toHonoHandler(router));
87
+ app.route('/api', toHono(router));
88
88
  ```
89
89
 
90
90
  ### With Custom Context
@@ -109,7 +109,7 @@ const router = createRouter<AppContext>({
109
109
  });
110
110
 
111
111
  const app = new Hono();
112
- app.route('/api', toHonoHandler(router));
112
+ app.route('/api', toHono(router));
113
113
  ```
114
114
 
115
115
  ### Multiple Routers
@@ -119,8 +119,8 @@ const usersRouter = createRouter({ routes: [/* user routes */] });
119
119
  const postsRouter = createRouter({ routes: [/* post routes */] });
120
120
 
121
121
  const app = new Hono();
122
- app.route('/api/users', toHonoHandler(usersRouter));
123
- app.route('/api/posts', toHonoHandler(postsRouter));
122
+ app.route('/api/users', toHono(usersRouter));
123
+ app.route('/api/posts', toHono(postsRouter));
124
124
  ```
125
125
 
126
126
  ### Edge Runtime Example
@@ -128,7 +128,7 @@ app.route('/api/posts', toHonoHandler(postsRouter));
128
128
  ```typescript
129
129
  // Cloudflare Workers
130
130
  import { createRouter } from '@superfunctions/http';
131
- import { toHonoHandler } from '@superfunctions/http-hono';
131
+ import { toHono } from '@superfunctions/http-hono';
132
132
 
133
133
  const router = createRouter({
134
134
  routes: [
@@ -137,7 +137,7 @@ const router = createRouter({
137
137
  });
138
138
 
139
139
  const app = new Hono();
140
- app.route('/', toHonoHandler(router));
140
+ app.route('/', toHono(router));
141
141
 
142
142
  export default app;
143
143
  ```
@@ -186,7 +186,7 @@ const router = createRouter({
186
186
  });
187
187
 
188
188
  // Route accessible at: /api/hello
189
- app.route('/api', toHonoHandler(router));
189
+ app.route('/api', toHono(router));
190
190
  ```
191
191
 
192
192
  ### HEAD Requests
@@ -202,7 +202,7 @@ import type { Router } from '@superfunctions/http';
202
202
  import type { Hono } from 'hono';
203
203
 
204
204
  const myRouter: Router = createRouter({ routes: [...] });
205
- const honoApp: Hono = toHonoHandler(myRouter);
205
+ const honoApp: Hono = toHono(myRouter);
206
206
  ```
207
207
 
208
208
  ## Edge Runtime Support
package/dist/adapter.d.ts CHANGED
@@ -6,8 +6,13 @@ import { Hono } from 'hono';
6
6
  /**
7
7
  * Convert a @superfunctions/http Router to a Hono instance
8
8
  *
9
- * This registers all routes from the router with their respective HTTP methods.
10
9
  * Hono uses Web Standards natively, so translation is minimal.
10
+ *
11
+ * Usage:
12
+ * ```typescript
13
+ * const router = createRouter({ routes: [...] });
14
+ * app.route('/api', toHono(router));
15
+ * ```
11
16
  */
12
- export declare function toHonoHandler(router: Router): Hono;
17
+ export declare function toHono(router: Router): Hono;
13
18
  //# 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,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA6BlD"}
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,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAgB3C"}
package/dist/adapter.js CHANGED
@@ -5,30 +5,25 @@ import { Hono } from 'hono';
5
5
  /**
6
6
  * Convert a @superfunctions/http Router to a Hono instance
7
7
  *
8
- * This registers all routes from the router with their respective HTTP methods.
9
8
  * Hono uses Web Standards natively, so translation is minimal.
9
+ *
10
+ * Usage:
11
+ * ```typescript
12
+ * const router = createRouter({ routes: [...] });
13
+ * app.route('/api', toHono(router));
14
+ * ```
10
15
  */
11
- export function toHonoHandler(router) {
16
+ export function toHono(router) {
12
17
  const app = new Hono();
13
- // Get all routes from the router
14
- const routes = router.getRoutes();
15
- // Register each route with Hono
16
- for (const route of routes) {
17
- const method = route.method.toLowerCase();
18
- // Hono doesn't have a 'head' method, so we'll skip HEAD requests
19
- // or treat them as GET (HEAD is rare and usually handled automatically)
20
- if (method === 'head') {
21
- continue;
22
- }
23
- app[method](route.path, async (c) => {
24
- // Hono's c.req.raw is already a Web Standard Request
25
- const webRequest = c.req.raw;
26
- // Handle with router
27
- const webResponse = await router.handle(webRequest);
28
- // Return Web Standard Response (Hono handles this natively)
29
- return webResponse;
30
- });
31
- }
18
+ // Use catch-all to delegate all routing to the router
19
+ app.all('*', async (c) => {
20
+ // Hono's c.req.raw is already a Web Standard Request
21
+ const webRequest = c.req.raw;
22
+ // Handle with router (router does all routing)
23
+ const webResponse = await router.handle(webRequest);
24
+ // Return Web Standard Response (Hono handles this natively)
25
+ return webResponse;
26
+ });
32
27
  return app;
33
28
  }
34
29
  //# sourceMappingURL=adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,iCAAiC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAElC,gCAAgC;IAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAoC,CAAC;QAE5E,iEAAiE;QACjE,wEAAwE;QACxE,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,SAAS;QACX,CAAC;QAED,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAClC,qDAAqD;YACrD,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;YAE7B,qBAAqB;YACrB,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAEpD,4DAA4D;YAC5D,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,MAAc;IACnC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,sDAAsD;IACtD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACvB,qDAAqD;QACrD,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;QAE7B,+CAA+C;QAC/C,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAEpD,4DAA4D;QAC5D,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * @superfunctions/http-hono - Hono adapter
3
3
  */
4
- export { toHonoHandler } from './adapter.js';
4
+ export { toHono } 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,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * @superfunctions/http-hono - Hono adapter
3
3
  */
4
- export { toHonoHandler } from './adapter.js';
4
+ export { toHono } 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,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superfunctions/http-hono",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Hono adapter for @superfunctions/http",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",