Nuxt/lib/app/middleware.js
Sébastien Chopin 17650c25e0 Middleware feature 🔥
2017-02-03 15:09:38 +01:00

21 lines
491 B
JavaScript

<% if (middleware) { %>
let files = require.context('~/middleware', false, /^\.\/.*\.js$/)
let filenames = files.keys()
function getModule (filename) {
let file = files(filename)
return file.default
? file.default
: file
}
let middleware = {}
// Generate the middleware
for (let filename of filenames) {
let name = filename.replace(/^\.\//, '').replace(/\.js$/, '')
middleware[name] = getModule(filename)
}
export default middleware
<% } else { %>export default {}<% } %>