export default function(): PluginOption {
return {
name: 'name',
apply: 'serve',
configureServer(server) {
server.middlewares.use(() => ...)
}
}
}
const server = await createServer({...})
server.middlewares.use(...)
export default function(): PluginOption {
return {
name: 'name',
apply: 'serve',
configureServer (server) {
const myMiddleware = (req, res, next) => {
console.log('Middleware added ')
next()
}
server.middlewares.use(myMiddleware)
const middlewareStack = server.middlewares.stack
const myMiddlewareCopy = middlewareStack.pop()
middlewareStack.push(myMiddlewareCopy)
}
}
}