mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +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
|
||||
|
||||
```ts
|
||||
function addDevServerHandler (handler: NitroEventHandler): void
|
||||
function addDevServerHandler (handler: NitroDevEventHandler): void
|
||||
|
||||
export interface NitroEventHandler {
|
||||
handler: string;
|
||||
export interface NitroDevEventHandler {
|
||||
handler: EventHandler;
|
||||
route?: string;
|
||||
middleware?: boolean;
|
||||
lazy?: boolean;
|
||||
method?: string;
|
||||
}
|
||||
```
|
||||
|
||||
@ -130,7 +127,7 @@ A handler object with the following properties:
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
Path to event handler.
|
||||
The event handler.
|
||||
|
||||
- `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.
|
||||
|
||||
- `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
|
||||
|
||||
::code-group
|
||||
@ -168,18 +147,14 @@ export default defineNuxtModule({
|
||||
const resolver = createResolver(import.meta.url)
|
||||
|
||||
addDevServerHandler({
|
||||
handler: resolver.resolve('./runtime/uptime.get'),
|
||||
route: '/_handler'
|
||||
})
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
```ts [runtime/timer.get.ts]
|
||||
export default defineEventHandler(() => {
|
||||
handler: () => {
|
||||
return {
|
||||
body: `Response generated at ${new Date().toISOString()}`
|
||||
}
|
||||
},
|
||||
route: '/_handler'
|
||||
})
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user