Nuxt/test/fixtures/module/modules/middleware/index.js
2017-05-15 03:31:41 +04:30

19 lines
388 B
JavaScript
Executable File

module.exports = function middlewareModule (options) {
return new Promise((resolve, reject) => {
// Add /api endpoint
this.addServerMiddleware({
path: '/api',
handler (req, res, next) {
res.end('It works!')
}
})
// Add plain middleware
this.addServerMiddleware((req, res, next) => {
next()
})
// Resolve
resolve()
})
}