nuxt-openapi-hyperfetch 0.3.81-beta → 1.0.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.
Files changed (64) hide show
  1. package/README.md +220 -212
  2. package/dist/generators/components/connector-generator/templates.js +67 -17
  3. package/dist/generators/components/schema-analyzer/intent-detector.js +1 -12
  4. package/dist/generators/components/schema-analyzer/openapi-reader.js +10 -1
  5. package/dist/generators/components/schema-analyzer/resource-grouper.js +7 -0
  6. package/dist/generators/components/schema-analyzer/schema-field-mapper.js +1 -22
  7. package/dist/generators/components/schema-analyzer/types.d.ts +10 -0
  8. package/dist/generators/connectors/generator.d.ts +12 -0
  9. package/dist/generators/connectors/generator.js +115 -0
  10. package/dist/generators/connectors/runtime/connector-types.d.ts +147 -0
  11. package/dist/generators/connectors/runtime/connector-types.js +10 -0
  12. package/dist/generators/connectors/runtime/useCreateConnector.d.ts +26 -0
  13. package/dist/generators/connectors/runtime/useCreateConnector.js +156 -0
  14. package/dist/generators/connectors/runtime/useDeleteConnector.d.ts +30 -0
  15. package/dist/generators/connectors/runtime/useDeleteConnector.js +143 -0
  16. package/dist/generators/connectors/runtime/useGetAllConnector.d.ts +25 -0
  17. package/dist/generators/connectors/runtime/useGetAllConnector.js +127 -0
  18. package/dist/generators/connectors/runtime/useGetConnector.d.ts +15 -0
  19. package/dist/generators/connectors/runtime/useGetConnector.js +99 -0
  20. package/dist/generators/connectors/runtime/useUpdateConnector.d.ts +34 -0
  21. package/dist/generators/connectors/runtime/useUpdateConnector.js +211 -0
  22. package/dist/generators/connectors/runtime/zod-error-merger.d.ts +23 -0
  23. package/dist/generators/connectors/runtime/zod-error-merger.js +106 -0
  24. package/dist/generators/connectors/templates.d.ts +4 -0
  25. package/dist/generators/connectors/templates.js +376 -0
  26. package/dist/generators/connectors/types.d.ts +37 -0
  27. package/dist/generators/connectors/types.js +7 -0
  28. package/dist/generators/shared/runtime/useDeleteConnector.js +4 -2
  29. package/dist/generators/shared/runtime/useDetailConnector.d.ts +0 -1
  30. package/dist/generators/shared/runtime/useDetailConnector.js +9 -20
  31. package/dist/generators/shared/runtime/useFormConnector.js +4 -3
  32. package/dist/generators/use-async-data/runtime/useApiAsyncData.js +14 -5
  33. package/dist/generators/use-async-data/templates.js +20 -16
  34. package/dist/generators/use-fetch/templates.js +1 -1
  35. package/dist/index.js +1 -16
  36. package/dist/module/index.js +2 -3
  37. package/package.json +4 -3
  38. package/src/cli/prompts.ts +1 -7
  39. package/src/generators/components/connector-generator/templates.ts +97 -22
  40. package/src/generators/components/schema-analyzer/intent-detector.ts +1 -16
  41. package/src/generators/components/schema-analyzer/openapi-reader.ts +14 -1
  42. package/src/generators/components/schema-analyzer/resource-grouper.ts +9 -0
  43. package/src/generators/components/schema-analyzer/schema-field-mapper.ts +1 -26
  44. package/src/generators/components/schema-analyzer/types.ts +11 -0
  45. package/src/generators/connectors/generator.ts +137 -0
  46. package/src/generators/connectors/runtime/connector-types.ts +207 -0
  47. package/src/generators/connectors/runtime/useCreateConnector.ts +199 -0
  48. package/src/generators/connectors/runtime/useDeleteConnector.ts +179 -0
  49. package/src/generators/connectors/runtime/useGetAllConnector.ts +151 -0
  50. package/src/generators/connectors/runtime/useGetConnector.ts +120 -0
  51. package/src/generators/connectors/runtime/useUpdateConnector.ts +257 -0
  52. package/src/generators/connectors/runtime/zod-error-merger.ts +119 -0
  53. package/src/generators/connectors/templates.ts +481 -0
  54. package/src/generators/connectors/types.ts +39 -0
  55. package/src/generators/shared/runtime/useDeleteConnector.ts +4 -2
  56. package/src/generators/shared/runtime/useDetailConnector.ts +8 -19
  57. package/src/generators/shared/runtime/useFormConnector.ts +4 -3
  58. package/src/generators/use-async-data/runtime/useApiAsyncData.ts +16 -5
  59. package/src/generators/use-async-data/templates.ts +24 -16
  60. package/src/generators/use-fetch/templates.ts +1 -1
  61. package/src/index.ts +2 -19
  62. package/src/module/index.ts +2 -5
  63. package/docs/generated-components.md +0 -615
  64. package/docs/headless-composables-ui.md +0 -569
package/README.md CHANGED
@@ -1,309 +1,317 @@
1
1
  <p align="center">
2
- <img src="./public/nuxt-openapi-hyperfetch-logo.png" alt="Nuxt OpenAPI Hyperfetch logo" width="260" />
2
+ <img src="https://raw.githubusercontent.com/dmartindiaz/nuxt-openapi-hyperfetch/main/public/nuxt-openapi-hyperfetch-logo.png" alt="Nuxt OpenAPI Hyperfetch logo" width="260" />
3
3
  </p>
4
4
 
5
- # 🚀 Nuxt OpenAPI Generator
6
-
7
- **Generate type-safe, SSR-compatible Nuxt composables from OpenAPI/Swagger specifications.**
5
+ <p align="center">
6
+ <strong>Generate type-safe CRUD composables from your OpenAPI spec.</strong><br/>
7
+ One command. Full TypeScript. SSR-ready.
8
+ </p>
8
9
 
9
- 📖 **[Full documentation → nuxt-openapi-hyperfetch.netlify.app](https://nuxt-openapi-hyperfetch.netlify.app/)**
10
+ <p align="center">
11
+ <a href="https://nuxt-openapi-hyperfetch.netlify.app/">📖 Documentation</a> ·
12
+ <a href="#ready-to-use-usefetch-and-useasyncdata-composables">useFetch & useAsyncData</a> ·
13
+ <a href="#ready-to-use-nuxt-server-routes">Nuxt Server</a> ·
14
+ <a href="#connectors">Headless UI Connectors</a> ·
15
+ <a href="#installation">Installation</a> ·
16
+ <a href="#quick-start">Quick Start</a>
17
+ </p>
10
18
 
11
19
  ---
12
20
 
13
- Transform your API documentation into production-ready **100% Nuxt-native** code—`useFetch` composables, `useAsyncData` composables, and Nuxt Server Routes—with full TypeScript support, lifecycle callbacks, and request interception. Use it either as a CLI with `nxh generate` or as a Nuxt module wired directly from `nuxt.config.ts`.
14
-
15
- ---
21
+ ## Installation
16
22
 
17
- ## ✨ Features
23
+ ```bash
24
+ # Global CLI
25
+ npm install -g nuxt-openapi-hyperfetch
18
26
 
19
- - 🔒 **Type-Safe**: Full TypeScript support derived from your OpenAPI schema
20
- - **SSR Compatible**: Works seamlessly with Nuxt server-side rendering
21
- - 🔄 **Lifecycle Callbacks**: `onRequest`, `onSuccess`, `onError`, `onFinish`
22
- - 🌐 **Global Callbacks Plugin**: Define callbacks once, apply to all requests
23
- - 🛡️ **Request Interception**: Modify headers, body, and query params before sending
24
- - 🎯 **Smart Data Selection**: Pick specific fields with dot notation for nested paths
25
- - 🤖 **Auto Type Inference**: Transform response data with automatic TypeScript type inference
26
- - ⚡ **Automatic Generation**: Single command generates all composables and server routes
27
- - 💚 **100% Nuxt Native**: Generated composables use `useFetch` / `useAsyncData`; server routes use `defineEventHandler` — no third-party runtime required
28
- - 📦 **Zero Runtime Dependencies**: Generated code only uses Nuxt built-ins
29
- - 💡 **Developer Experience**: Interactive CLI with smart defaults
27
+ # Or as a Nuxt module (dev dependency)
28
+ npm install -D nuxt-openapi-hyperfetch
29
+ ```
30
30
 
31
31
  ---
32
32
 
33
- ## 🔧 Generator Engines
34
-
35
- Two generation engines are available. The CLI will ask you to choose one when running `nxh generate`:
33
+ ## What it does
36
34
 
37
- | Engine | Tool | Node Native | Best for |
38
- |--------|------|:---:|----------|
39
- | **official** | [@openapitools/openapi-generator-cli](https://openapi-generator.tech/) | ❌ Requires Java 11+ | Maximum spec compatibility, enterprise projects |
40
- | **heyapi** | [@hey-api/openapi-ts](https://heyapi.dev/) | ✅ Yes | Quick setup, CI/CD pipelines, Node-only environments |
35
+ Point it at an OpenAPI spec, pick an output folder, run one command. You get four kinds of output:
41
36
 
42
- > The CLI checks for Java automatically when `official` is selected and aborts with an install link if it is not found. Get Java at [adoptium.net](https://adoptium.net).
37
+ - **`useFetch` composables** one per endpoint, reactive, bound to template lifecycle
38
+ - **`useAsyncData` composables** — SSR-compatible, awaitable, ideal for page-level data
39
+ - **Nuxt Server Routes** — generated proxy endpoints that keep API keys server-side
40
+ - **Connectors** — headless UI composables (one per resource tag) that combine list, detail, create, update, and delete into a single import — with Zod validation, modal state, reactive params, and pagination built in
43
41
 
44
- You can also pre-select the engine in your `nxh.config.js` the CLI will skip the prompt entirely:
45
-
46
- ```js
47
- // nxh.config.js
48
- export default {
49
- generator: 'openapi', // 'openapi' | 'heyapi'
50
- input: './swagger.yaml',
51
- output: './api',
52
- };
53
- ```
42
+ All output is 100% Nuxt-native. No runtime dependencies in the generated code.
54
43
 
55
44
  ---
56
45
 
57
- ## 📦 Installation
46
+ ## Ready to use: `useFetch` and `useAsyncData` composables
58
47
 
59
- ### Use as CLI
48
+ One composable per endpoint, for when you need direct control:
60
49
 
61
- ```bash
62
- npm install -g nuxt-openapi-hyperfetch
63
- # or
64
- yarn global add nuxt-openapi-hyperfetch
65
- # or
66
- pnpm add -g nuxt-openapi-hyperfetch
67
- ```
68
-
69
- Or use directly with npx:
50
+ ```ts
51
+ // useFetch reactive, bound to template lifecycle
52
+ const { data: pet, pending, error } = useFetchGetPetById({ petId: 123 })
70
53
 
71
- ```bash
72
- npx nuxt-openapi-hyperfetch generate
54
+ // useAsyncData — SSR-compatible, awaitable
55
+ const { data: pets } = await useAsyncDataFindPets({ status: 'available' })
73
56
  ```
74
57
 
75
- ### Use as Nuxt module
58
+ With callbacks and request modification:
76
59
 
77
- Install it in your Nuxt project:
60
+ ```ts
61
+ // useFetch — onRequest receives ctx and must return modifications
62
+ const { data } = useFetchFindPets(
63
+ { status: 'available' },
64
+ {
65
+ onRequest: (ctx) => {
66
+ // ctx: { url, method, headers, query, body }
67
+ return { headers: { 'X-Source': 'pets-page' } }
68
+ },
69
+ onSuccess: (pets) => console.log(`${pets.length} pets loaded`),
70
+ onError: (err) => console.error(err.message),
71
+ onFinish: ({ success }) => console.log('Done:', success),
72
+ }
73
+ )
78
74
 
79
- ```bash
80
- npm install -D nuxt-openapi-hyperfetch
81
- # or
82
- pnpm add -D nuxt-openapi-hyperfetch
83
- # or
84
- yarn add -D nuxt-openapi-hyperfetch
75
+ // useAsyncData — onSuccess and onError receive a second context argument
76
+ const { data: pets } = await useAsyncDataFindPets(
77
+ { status: 'available' },
78
+ {
79
+ onRequest: (ctx) => ({ headers: { 'X-Source': 'pets-page' } }),
80
+ onSuccess: (pets, ctx) => console.log(`${pets.length} from ${ctx.url}`),
81
+ onError: (err, ctx) => console.error(err.message, ctx.url),
82
+ }
83
+ )
85
84
  ```
86
85
 
87
- Then register the module in `nuxt.config.ts`:
86
+ ---
88
87
 
89
- ```ts
90
- export default defineNuxtConfig({
91
- modules: ['nuxt-openapi-hyperfetch'],
88
+ ## Ready to use: Nuxt Server Routes
92
89
 
93
- openApiHyperFetch: {
94
- input: './swagger.yaml',
95
- output: './composables/api',
96
- generators: ['useFetch', 'useAsyncData'],
97
- backend: 'heyapi',
98
- enableDevBuild: true,
99
- enableProductionBuild: true,
100
- enableAutoGeneration: false,
101
- enableAutoImport: true,
102
- createUseAsyncDataConnectors: false,
103
- },
104
- })
90
+ Proxy endpoints to keep API keys server-side:
91
+
92
+ ```
93
+ Client Nuxt Server Route (generated) → External API
105
94
  ```
106
95
 
107
- The module uses `openApiHyperFetch` as its Nuxt config key and runs generation during Nuxt build hooks. If you include `nuxtServer` in `generators`, you can also configure `serverRoutePath` and `enableBff` here.
96
+ ```ts
97
+ // Works automatically after generation
98
+ const { data } = useFetch('/api/pet/123')
99
+ ```
108
100
 
109
101
  ---
110
102
 
111
- ## 🚀 Quick Start
103
+ ## Connectors
112
104
 
113
- ### 1. Run the generator with the CLI
105
+ A connector exposes five sub-composables for one resource. For a `pet` tag in your spec:
114
106
 
115
- <p align="center">
116
- <img src="./public/nuxt-openapi-hyperfetch-cli.png" alt="Nuxt OpenAPI Hyperfetch CLI" width="720" />
117
- </p>
118
-
119
- ```bash
120
- nxh generate
107
+ ```ts
108
+ const { getAll, get, create, update, del } = usePetsConnector()
121
109
  ```
122
110
 
123
- The CLI will ask you for:
111
+ ### Full CRUD page in one component
124
112
 
125
- - 📂 Path to your OpenAPI/Swagger file (`.yaml` or `.json`)
126
- - 📁 Output directory for generated files
127
- - 🔧 Which generation engine to use (`official` or `heyapi`)
128
- - ✅ Which composables to generate (`useFetch`, `useAsyncData`, `Nuxt server routes`)
113
+ ```vue
114
+ <script setup lang="ts">
115
+ const { getAll, create, update, del } = usePetsConnector()
129
116
 
130
- Or pass arguments directly:
117
+ // Reload the list after every mutation
118
+ create.onSuccess(() => getAll.load())
119
+ update.onSuccess(() => getAll.load())
120
+ del.onSuccess(() => getAll.load())
121
+ </script>
131
122
 
132
- ```bash
133
- nxh generate -i ./swagger.yaml -o ./api
123
+ <template>
124
+ <!-- List -->
125
+ <UTable
126
+ :columns="getAll.columns.value"
127
+ :rows="getAll.items.value"
128
+ :loading="getAll.loading.value"
129
+ >
130
+ <template #actions-data="{ row }">
131
+ <UButton @click="update.ui.open(row)">Edit</UButton>
132
+ <UButton color="red" @click="del.ui.open(row)">Delete</UButton>
133
+ </template>
134
+ </UTable>
135
+
136
+ <!-- Create -->
137
+ <UButton @click="create.ui.open()">Add pet</UButton>
138
+ <UModal v-model:open="create.ui.isOpen.value">
139
+ <UCard>
140
+ <UFormField label="Name" :error="create.errors.value.name?.[0]">
141
+ <UInput v-model="create.model.value.name" />
142
+ </UFormField>
143
+ <UFormField label="Status">
144
+ <USelect v-model="create.model.value.status"
145
+ :options="['available','pending','sold']" />
146
+ </UFormField>
147
+ <template #footer>
148
+ <UButton :loading="create.loading.value" @click="create.execute()">Save</UButton>
149
+ </template>
150
+ </UCard>
151
+ </UModal>
152
+
153
+ <!-- Edit -->
154
+ <UModal v-model:open="update.ui.isOpen.value">
155
+ <UCard>
156
+ <UInput v-model="update.model.value.name" />
157
+ <template #footer>
158
+ <UButton :loading="update.loading.value"
159
+ @click="update.execute(update.model.value.id)">Save changes</UButton>
160
+ </template>
161
+ </UCard>
162
+ </UModal>
163
+
164
+ <!-- Delete confirmation -->
165
+ <UModal v-model:open="del.ui.isOpen.value">
166
+ <UCard>
167
+ <p>Delete <strong>{{ del.staged.value?.name }}</strong>?</p>
168
+ <template #footer>
169
+ <UButton color="red" :loading="del.loading.value" @click="del.execute()">Delete</UButton>
170
+ <UButton variant="outline" @click="del.ui.close()">Cancel</UButton>
171
+ </template>
172
+ </UCard>
173
+ </UModal>
174
+ </template>
134
175
  ```
135
176
 
136
- ### 2. Or generate through the Nuxt module
177
+ ### What each sub-connector provides
137
178
 
138
- If you prefer generation to run from Nuxt itself, add the module and configure it in `nuxt.config.ts`:
179
+ | Key | Transport | What you get |
180
+ |---|---|---|
181
+ | `getAll` | `useAsyncData` | `items`, `columns`, `loading`, `error`, `pagination`, `selected`, `load()` |
182
+ | `get` | `$fetch` | `data`, `loading`, `error`, `load(id)`, `clear()` |
183
+ | `create` | `$fetch` | `model`, `errors`, `isValid`, `execute()`, `reset()`, `ui.open/close` |
184
+ | `update` | `$fetch` | Same as create + `load(id)`, `ui.open(row)`, `targetId` |
185
+ | `del` | `$fetch` | `staged`, `hasStaged`, `execute()`, `ui.open(item)/close` |
186
+
187
+ ### Reactive list parameters
139
188
 
140
189
  ```ts
141
- export default defineNuxtConfig({
142
- modules: ['nuxt-openapi-hyperfetch'],
190
+ const status = ref('available')
143
191
 
144
- openApiHyperFetch: {
145
- input: './swagger.yaml',
146
- output: './composables/api',
147
- generators: ['useFetch', 'useAsyncData', 'nuxtServer'],
148
- backend: 'heyapi',
149
- serverRoutePath: 'server/routes/api',
150
- enableBff: false,
151
- enableAutoImport: true,
152
- enableAutoGeneration: true,
153
- },
154
- })
192
+ // Re-fetches automatically when status changes
193
+ const { getAll } = usePetsConnector(() => ({ status: status.value }))
155
194
  ```
156
195
 
157
- Useful module options:
196
+ ### Zod validation, out of the box
158
197
 
159
- - `input`: OpenAPI file path relative to the Nuxt root.
160
- - `output`: Directory where the generated SDK/composables are written.
161
- - `generators`: Any combination of `useFetch`, `useAsyncData`, and `nuxtServer`.
162
- - `backend`: `heyapi` or `official`.
163
- - `enableDevBuild` / `enableProductionBuild`: Control generation before dev/build.
164
- - `enableAutoGeneration`: Regenerate when the input spec changes in dev mode.
165
- - `enableAutoImport`: Auto-register generated composables for Nuxt auto-imports.
166
- - `createUseAsyncDataConnectors`: Generate headless connectors on top of `useAsyncData`.
167
- - `serverRoutePath`: Output path for generated Nuxt server routes.
168
- - `enableBff`: Enable the BFF transformer layer for server routes.
198
+ Schemas are generated from your OpenAPI `requestBody`. `create.execute()` validates before sending — the network call is never made if the data is invalid.
169
199
 
170
- ### 3. Generated output
171
-
172
- ```
173
- api/
174
- +-- runtime.ts
175
- +-- apis/
176
- │ +-- PetApi.ts
177
- │ +-- StoreApi.ts
178
- +-- models/
179
- │ +-- Pet.ts
180
- │ +-- Order.ts
181
- +-- composables/
182
- +-- use-fetch/
183
- +-- runtime/
184
- │ +-- useApiRequest.ts
185
- +-- composables/
186
- │ +-- useFetchGetPetById.ts
187
- │ +-- useFetchAddPet.ts
188
- +-- index.ts
200
+ ```ts
201
+ // Extend the generated schema for extra rules
202
+ const { create } = usePetsConnector({}, {
203
+ createSchema: (base) => base.extend({
204
+ name: z.string().min(2, 'At least 2 characters'),
205
+ })
206
+ })
189
207
  ```
190
208
 
191
- ### 4. Configure the API base URL
209
+ ### Global callbacks
192
210
 
193
- Add to `nuxt.config.ts`:
211
+ Register once, applies to every API call in the app:
194
212
 
195
- ```typescript
196
- export default defineNuxtConfig({
197
- runtimeConfig: {
198
- public: {
199
- apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com'
200
- }
213
+ ```ts
214
+ // plugins/api-callbacks.plugin.ts
215
+ defineGlobalApiCallbacks([
216
+ {
217
+ onRequest: (ctx) => ({
218
+ headers: { Authorization: `Bearer ${useAuthStore().token}` }
219
+ }),
220
+ onError: (err) => useToast().add({ title: err.message, color: 'red' }),
201
221
  }
202
- })
222
+ ])
203
223
  ```
204
224
 
205
- And in `.env`:
225
+ Connector-level and per-operation callbacks are also available — see [Callbacks docs](./docs/connectors/callbacks.md).
206
226
 
207
- ```env
208
- NUXT_PUBLIC_API_BASE_URL=https://api.example.com
209
- ```
227
+ ---
210
228
 
211
- All generated `useFetch` and `useAsyncData` composables will automatically use this as `baseURL`. You can still override it per-composable via `options.baseURL`.
229
+ ## Quick Start
212
230
 
213
- ### 5. Use in your Nuxt app
231
+ ### CLI
214
232
 
215
- ```vue
216
- <script setup lang="ts">
217
- import { useFetchGetPetById } from '@/api/composables/use-fetch';
218
-
219
- const { data: pet, pending, error } = useFetchGetPetById(
220
- { petId: 123 },
221
- {
222
- onSuccess: (pet) => console.log('Loaded:', pet.name),
223
- onError: (err) => console.error('Failed:', err),
224
- }
225
- );
226
- </script>
233
+ <p align="center">
234
+ <img src="https://raw.githubusercontent.com/dmartindiaz/nuxt-openapi-hyperfetch/main/public/nuxt-openapi-hyperfetch-cli.png" alt="Nuxt OpenAPI Hyperfetch CLI" width="720" />
235
+ </p>
227
236
 
228
- <template>
229
- <div>
230
- <div v-if="pending">Loading...</div>
231
- <div v-else-if="error">Error: {{ error }}</div>
232
- <div v-else-if="pet">{{ pet.name }} — {{ pet.status }}</div>
233
- </div>
234
- </template>
237
+ ```bash
238
+ nxh generate
239
+ # or with arguments:
240
+ nxh generate -i ./swagger.yaml -o ./composables/api
235
241
  ```
236
242
 
237
- ---
243
+ The CLI asks for your spec path, output folder, engine (`heyapi` or `official`), and which generators to run.
238
244
 
239
- ## 🖥️ Nuxt Server Routes Generator
245
+ ### Nuxt module
240
246
 
241
- In addition to client-side composables, you can generate **Nuxt Server Routes** that proxy requests to your backend API—keeping API keys and secrets server-side.
247
+ ```ts
248
+ // nuxt.config.ts
249
+ export default defineNuxtConfig({
250
+ modules: ['nuxt-openapi-hyperfetch'],
242
251
 
243
- ```
244
- Client → Nuxt Server Route (generated) → External API
252
+ openApiHyperFetch: {
253
+ input: './swagger.yaml',
254
+ output: './composables/api',
255
+ generators: ['useFetch', 'useAsyncData', 'nuxtServer'],
256
+ backend: 'heyapi',
257
+ enableAutoImport: true,
258
+ },
259
+ })
245
260
  ```
246
261
 
247
- After generation, configure your backend URL in `.env`:
262
+ ### Configure the base URL
248
263
 
249
- ```env
250
- API_BASE_URL=https://your-backend-api.com/api
251
- API_SECRET=your-secret-token
264
+ ```ts
265
+ // nuxt.config.ts
266
+ runtimeConfig: {
267
+ public: { apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'https://api.example.com' }
268
+ }
252
269
  ```
253
270
 
254
- And add it to `nuxt.config.ts`:
271
+ All generated composables and connectors pick up `apiBaseUrl` automatically.
255
272
 
256
- ```typescript
257
- export default defineNuxtConfig({
258
- runtimeConfig: {
259
- // Private — server-side only (never exposed to the browser)
260
- apiBaseUrl: process.env.API_BASE_URL || '',
261
- apiSecret: process.env.API_SECRET || '',
262
- },
263
- });
264
- ```
273
+ ---
265
274
 
266
- > **Note:** `runtimeConfig.apiBaseUrl` (private) is only for **Server Routes**. For `useFetch`/`useAsyncData` composables use `runtimeConfig.public.apiBaseUrl` instead — see the [Quick Start](#-quick-start) section above.
275
+ ## Two generation engines
267
276
 
268
- Then use standard `useFetch` against your Nuxt routes:
277
+ | Engine | Requires | Best for |
278
+ |---|---|---|
279
+ | `heyapi` | Node only | Quick setup, CI/CD |
280
+ | `official` | Java 11+ | Maximum spec compatibility |
269
281
 
270
- ```typescript
271
- const { data: pet } = useFetch('/api/pet/123');
272
- ```
282
+ Pre-select in `nxh.config.js` to skip the prompt:
273
283
 
274
- > **BFF (Backend for Frontend) mode** is also available — generates a transformer layer for auth context, data enrichment, and permission filtering without ever overwriting your custom code. See the [Server Routes Guide](./docs/DEVELOPMENT.md) for details.
284
+ ```js
285
+ export default { generator: 'heyapi', input: './swagger.yaml', output: './api' }
286
+ ```
275
287
 
276
288
  ---
277
289
 
278
- ## 📚 Documentation
290
+ ## Documentation
279
291
 
280
- | Guide | Description |
281
- |-------|-------------|
282
- | [Quick Start Guide](./docs/QUICK-START.md) | Understand the project in 5 minutes |
283
- | [Architecture](./docs/ARCHITECTURE.md) | Design patterns, two-stage generation, shared code |
284
- | [API Reference](./docs/API-REFERENCE.md) | All CLI options, TypeScript types, composable APIs |
285
- | [Development Guide](./docs/DEVELOPMENT.md) | Contributing, adding generators, code style |
292
+ | | |
293
+ |---|---|
294
+ | [Connectors](./docs/connectors/index.md) | Full connector API reference and examples |
295
+ | [Quick Start](./docs/QUICK-START.md) | From zero to working composables in 5 minutes |
296
+ | [API Reference](./docs/API-REFERENCE.md) | All options and TypeScript types |
297
+ | [Architecture](./docs/ARCHITECTURE.md) | How the generator works internally |
286
298
  | [Troubleshooting](./docs/TROUBLESHOOTING.md) | Common errors and solutions |
287
299
 
288
300
  ---
289
301
 
290
- ## 🤝 Contributing
291
-
292
- Contributions are welcome! Please read the [Contributing Guidelines](./CONTRIBUTING.md) before submitting a PR.
302
+ ## Contributing
293
303
 
294
304
  ```bash
295
- # Development setup
296
305
  npm install
297
306
  npm run build
298
307
  npm run validate # lint + type check
299
308
  ```
300
309
 
301
- ---
310
+ See [CONTRIBUTING.md](./CONTRIBUTING.md).
302
311
 
303
- ## 📄 License
304
-
305
- Apache-2.0 — see [LICENSE](./LICENSE) for details.
306
312
 
307
313
  ---
308
314
 
309
- **Made with ❤️ for Nuxt developers**
315
+ ## License
316
+
317
+ Apache-2.0 — see [LICENSE](./LICENSE) for details.