8000 fix(nitro): also augment `nuxt/schema` · nuxt/nuxt@9b40196 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b40196

Browse files
committed
fix(nitro): also augment nuxt/schema
1 parent 9cb9a19 commit 9b40196

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
< 9B5A td data-grid-cell-id="diff-a16c3331ef7156cbd08e957d05a23c59ff6054986c2c581056267dfa5a80d120-140-228-2" data-line-anchor="diff-a16c3331ef7156cbd08e957d05a23c59ff6054986c2c581056267dfa5a80d120R228" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionLine-bgColor, var(--diffBlob-addition-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">+
}
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,109 @@ declare module '@nuxt/schema' {
138138
}
139139
}
140140

141+
declare module 'nuxt/schema' {
142+
interface NuxtHooks {
143+
/**
144+
* Called when the dev middleware is being registered on the Nitro dev server.
145+
* @param handler the Vite or Webpack event handler
146+
* @returns Promise
147+
*/
148+
'server:devHandler': (handler: EventHandler, options: { cors: (path: string) => boolean }) => HookResult
149+
150+
/**
151+
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
152+
* @param options Objects containing `references`, `declarations`
153+
* @returns Promise
154+
*/
155+
'nitro:prepare:types': (options: { references: TSReference[], declarations: string[] }) => HookResult
156+
/**
157+
* Called before initializing Nitro, allowing customization of Nitro's configuration.
158+
* @param nitroConfig The nitro config to be extended
159+
* @returns Promise
160+
*/
161+
'nitro:config': (nitroConfig: NitroConfig) => HookResult
162+
/**
163+
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
164+
* @param nitro The created nitro object
165+
* @returns Promise
166+
*/
167+
'nitro:init': (nitro: Nitro) => HookResult
168+
/**
169+
* Called before building the Nitro instance.
170+
* @param nitro The created nitro object
171+
* @returns Promise
172+
*/
173+
'nitro:build:before': (nitro: Nitro) => HookResult
174+
/**
175+
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
176+
* @param nitro The created nitro object
177+
* @returns Promise
178+
*/
179+
'nitro:build:public-assets': (nitro: Nitro) => HookResult
180+
}
181+
182+
interface ConfigSchema {
183+
/**
184+
* Configuration for Nitro.
185+
*
186+
* @see [Nitro configuration docs](https://nitro.build/config)
187+
*/
188+
nitro: NitroConfig
189+
190+
/**
191+
* Global route options applied to matching server routes.
192+
*
193+
* @experimental This is an experimental feature and API may change in the future.
194+
*
195+
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
196+
*/
197+
routeRules: NitroConfig['routeRules']
198+
199+
/**
200+
* Nitro server handlers.
201+
*
202+
* Each handler accepts the following options:
203+
* - 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.
204+
*
205+
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
206+
*
207+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
208+
*
209+
* @example
210+
* ```js
211+
* serverHandlers: [
212+
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
213+
* ]
214+
* ```
215+
*/
216+
serverHandlers: NitroEventHandler[]
217+
218+
/**
219+
* Nitro development-only server handlers.
220+
*
221+
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
222+
*/
223+
devServerHandlers: NitroDevEventHandler[]
224+
}
225+
226+
interface NuxtConfig {
227+
nitro?: NitroConfig
228
229+
230+
interface RuntimeConfig {
231+
app: NitroRuntimeConfigApp
232+
/** Only available on the server. */
233+
nitro?: NitroRuntimeConfig['nitro']
234+
}
235+
236+
interface NuxtDebugOptions {
237+
/** Debug options for Nitro */
238+
nitro?: NitroOptions['debug']
239+
}
240+
241+
interface NuxtPage {
242+
rules?: NitroRouteConfig
243+
}
244+
}
245+
141246
export {}

0 commit comments

Comments
 (0)
0