Skip to content

Commit 552bbd8

Browse files
committed
fix(nitro): augment nuxt/schema once more
This reverts commit d72f180.
1 parent cb054d4 commit 552bbd8

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

packages/nitro-server/src/augments.ts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,109 @@ declare module '@nuxt/schema' {
171171
}
172172
}
173173

174+
declare module 'nuxt/schema' {
175+
interface NuxtHooks {
176+
/**
177+
* Called when the dev middleware is being registered on the Nitro dev server.
178+
* @param handler the Vite or Webpack event handler
179+
* @returns Promise
180+
*/
181+
'server:devHandler': (handler: EventHandler, options: { cors: (path: string) => boolean }) => HookResult
182+
183+
/**
184+
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
185+
* @param options Objects containing `references`, `declarations`
186+
* @returns Promise
187+
*/
188+
'nitro:prepare:types': (options: { references: TSReference[], declarations: string[] }) => HookResult
189+
/**
190+
* Called before initializing Nitro, allowing customization of Nitro's configuration.
191+
* @param nitroConfig The nitro config to be extended
192+
* @returns Promise
193+
*/
194+
'nitro:config': (nitroConfig: NitroConfig) => HookResult
195+
/**
196+
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
197+
* @param nitro The created nitro object
198+
* @returns Promise
199+
*/
200+
'nitro:init': (nitro: Nitro) => HookResult
201+
/**
202+
* Called before building the Nitro instance.
203+
* @param nitro The created nitro object
204+
* @returns Promise
205+
*/
206+
'nitro:build:before': (nitro: Nitro) => HookResult
207+
/**
208+
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
209+
* @param nitro The created nitro object
210+
* @returns Promise
211+
*/
212+
'nitro:build:public-assets': (nitro: Nitro) => HookResult
213+
}
214+
215+
interface ConfigSchema {
216+
/**
217+
* Configuration for Nitro.
218+
*
219+
* @see [Nitro configuration docs](https://nitro.build/config)
220+
*/
221+
nitro: NitroConfig
222+
223+
/**
224+
* Global route options applied to matching server routes.
225+
*
226+
* @experimental This is an experimental feature and API may change in the future.
227+
*
228+
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
229+
*/
230+
routeRules: NitroConfig['routeRules']
231+
232+
/**
233+
* Nitro server handlers.
234+
*
235+
* Each handler accepts the following options:
236+
* - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
237+
*
238+
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
239+
*
240+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
241+
*
242+
* @example
243+
* ```js
244+
* serverHandlers: [
245+
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
246+
* ]
247+
* ```
248+
*/
249+
serverHandlers: NitroEventHandler[]
250+
251+
/**
252+
* Nitro development-only server handlers.
253+
*
254+
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
255+
*/
256+
devServerHandlers: NitroDevEventHandler[]
257+
}
258+
259+
interface NuxtConfig {
260+
nitro?: NitroConfig
261+
}
262+
263+
interface RuntimeConfig {
264+
app: NitroRuntimeConfigApp
265+
/** Only available on the server. */
266+
nitro?: NitroRuntimeConfig['nitro']
267+
}
268+
269+
interface NuxtDebugOptions {
270+
/** Debug options for Nitro */
271+
nitro?: NitroOptions['debug']
272+
}
273+
274+
interface NuxtPage {
275+
rules?: NitroRouteConfig
276+
}
277+
}
278+
174279
export {}

0 commit comments

Comments
 (0)