mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
docs: fix addDevServerHandler
API (#25233)
This commit is contained in:
parent
986786a4a9
commit
18d279336d
@ -105,14 +105,11 @@ Adds a nitro server handler to be used only in development mode. This handler wi
|
|||||||
### Type
|
### Type
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
function addDevServerHandler (handler: NitroEventHandler): void
|
function addDevServerHandler (handler: NitroDevEventHandler): void
|
||||||
|
|
||||||
export interface NitroEventHandler {
|
export interface NitroDevEventHandler {
|
||||||
handler: string;
|
handler: EventHandler;
|
||||||
route?: string;
|
route?: string;
|
||||||
middleware?: boolean;
|
|
||||||
lazy?: boolean;
|
|
||||||
method?: string;
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -130,7 +127,7 @@ A handler object with the following properties:
|
|||||||
|
|
||||||
**Type**: `string`
|
**Type**: `string`
|
||||||
|
|
||||||
Path to event handler.
|
The event handler.
|
||||||
|
|
||||||
- `route` (optional)
|
- `route` (optional)
|
||||||
|
|
||||||
@ -138,24 +135,6 @@ A handler object with the following properties:
|
|||||||
|
|
||||||
Path prefix or route. If an empty string used, will be used as a middleware.
|
Path prefix or route. If an empty string used, will be used as a middleware.
|
||||||
|
|
||||||
- `middleware` (optional)
|
|
||||||
|
|
||||||
**Type**: `boolean`
|
|
||||||
|
|
||||||
Specifies this is a middleware handler. Middleware are called on every route and should normally return nothing to pass to the next handlers.
|
|
||||||
|
|
||||||
- `lazy` (optional)
|
|
||||||
|
|
||||||
**Type**: `boolean`
|
|
||||||
|
|
||||||
Use lazy loading to import handler.
|
|
||||||
|
|
||||||
- `method` (optional)
|
|
||||||
|
|
||||||
**Type**: `string`
|
|
||||||
|
|
||||||
Router method matcher.
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
::code-group
|
::code-group
|
||||||
@ -168,18 +147,14 @@ export default defineNuxtModule({
|
|||||||
const resolver = createResolver(import.meta.url)
|
const resolver = createResolver(import.meta.url)
|
||||||
|
|
||||||
addDevServerHandler({
|
addDevServerHandler({
|
||||||
handler: resolver.resolve('./runtime/uptime.get'),
|
handler: () => {
|
||||||
route: '/_handler'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
```ts [runtime/timer.get.ts]
|
|
||||||
export default defineEventHandler(() => {
|
|
||||||
return {
|
return {
|
||||||
body: `Response generated at ${new Date().toISOString()}`
|
body: `Response generated at ${new Date().toISOString()}`
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
route: '/_handler'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user