fix(kit): add typings to kit server middleware (#3776)

Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
Matteo Rigoni 2022-04-04 10:21:30 +02:00 committed by GitHub
parent d5b7b5882c
commit 01db83032a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ export default defineBuildConfig({
externals: [
'@nuxt/schema',
'webpack',
'vite'
'vite',
'h3'
]
})

View File

@ -1,6 +1,12 @@
import type { Middleware } from 'h3'
import { useNuxt } from './context'
export interface ServerMiddleware {
path?: string,
handler: Middleware | string
}
/** Adds a new server middleware to the end of the server middleware array. */
export function addServerMiddleware (middleware) {
export function addServerMiddleware (middleware: ServerMiddleware) {
useNuxt().options.serverMiddleware.push(middleware)
}