Nuxt/test/fixtures/module/modules/middleware/index.js

19 lines
388 B
JavaScript
Raw Normal View History

2017-05-14 22:45:01 +00:00
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!')
}
})
2017-05-14 23:01:41 +00:00
// Add plain middleware
this.addServerMiddleware((req, res, next) => {
next()
})
// Resolve
resolve()
2017-05-14 22:45:01 +00:00
})
}