@sdk-it/hono 0.13.0 → 0.14.2

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 +22 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -18,7 +18,7 @@ You can use these functions without the SDK-IT code generation tools, they're co
18
18
 
19
19
  The validator middleware offers type-safe request validation using [Zod](https://github.com/colinhacks/zod) schemas. It automatically validates incoming requests against your defined schemas and provides typed inputs to your handlers.
20
20
 
21
- > ![IMPORTANT]
21
+ > [!IMPORTANT]
22
22
  > For openapi generation to work correctly, you must use the `validate` middleware for each route.
23
23
 
24
24
  ```typescript
@@ -86,7 +86,7 @@ The output function provides a clean API for sending HTTP responses with proper
86
86
 
87
87
  The `output` utility builds on hono's `context.body`.
88
88
 
89
- > ![NOTE]
89
+ > [!NOTE]
90
90
  > You don't necessarily need to use this function for OpenAPI generation, but it provides a clean and consistent way to send responses.
91
91
 
92
92
  ```typescript
@@ -147,14 +147,15 @@ app.get(
147
147
  );
148
148
  ```
149
149
 
150
- > ![TIP]
151
- > Instead of using `createOutput` fn, you can use [context-storage](https://hono.dev/docs/middleware/builtin/context-storage) middleware and then import the global `output` object from `@sdk-it/generic`.
150
+ > [!TIP]
151
+ > Instead of using `createOutput` fn, you can use [context-storage](https://hono.dev/docs/middleware/builtin/context-storage) middleware and then import the global `output` object from `@sdk-it/hono/runtime`.
152
152
 
153
153
  - Use the generate fn to create an OpenAPI spec from your routes.
154
154
 
155
- <small>filename: openapi.ts</small>
155
+ <b><small>filename: openapi.ts</small></b>
156
156
 
157
157
  ```typescript
158
+ import { writeFile } from 'node:fs/promises';
158
159
  import { join } from 'node:path';
159
160
 
160
161
  import { analyze } from '@sdk-it/generic';
@@ -182,6 +183,12 @@ const spec = {
182
183
  paths,
183
184
  components,
184
185
  };
186
+
187
+ // Save the spec to a file
188
+ await writeFile('openapi.json', JSON.stringify(spec, null, 2));
189
+ // OR
190
+
191
+ // Continue to generate an SDK
185
192
  await generate(spec, {
186
193
  output: join(process.cwd(), './client'),
187
194
  });
@@ -200,8 +207,17 @@ npx tsx ./openapi.ts
200
207
  bun ./openapi.ts
201
208
  ```
202
209
 
210
+ <details>
211
+ <summary> Run in watch mode </summary>
212
+
213
+ ```bash
214
+ node --experimental-strip-types --watch-path ./apps/backend/src --watch ./openapi.ts
215
+ ```
216
+
217
+ </details>
218
+
203
219
  > [!TIP]
204
- > See [typescript](../typescript/README.md) for more info.
220
+ > See [the typescript package](../typescript/README.md) for more info.
205
221
 
206
222
  - Use the client
207
223
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-it/hono",
3
- "version": "0.13.0",
3
+ "version": "0.14.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "!**/*.tsbuildinfo"
27
27
  ],
28
28
  "dependencies": {
29
- "@sdk-it/core": "0.13.0",
29
+ "@sdk-it/core": "0.14.2",
30
30
  "hono": "^4.7.4",
31
31
  "typescript": "^5.7.2",
32
32
  "zod": "^3.24.2"