mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
feat: describe addServerHandler
This commit is contained in:
parent
aa75b8c320
commit
7e9ff791e7
@ -2029,7 +2029,63 @@ export default defineNuxtModule({
|
||||
|
||||
[source code](https://github.com/nuxt/nuxt/blob/main/packages/kit/src/nitro.ts)
|
||||
|
||||
### `addServerHandler (handler)`
|
||||
### `addServerHandler`
|
||||
|
||||
Adds a nitro server handler.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
function addServerHandler (handler: NitroEventHandler): void
|
||||
|
||||
export interface NitroEventHandler {
|
||||
handler: string;
|
||||
route?: string;
|
||||
middleware?: boolean;
|
||||
lazy?: boolean;
|
||||
method?: string;
|
||||
}
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `handler`
|
||||
|
||||
**Type**: `NitroEventHandler`
|
||||
|
||||
**Required**: `true`
|
||||
|
||||
A handler object with the following properties:
|
||||
|
||||
- `handler` (required)
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
Path to event handler.
|
||||
|
||||
- `route` (optional)
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
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.
|
||||
|
||||
### `addDevServerHandler (handler)`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user