2017-02-03 14:09:27 +00:00
|
|
|
<% if (middleware) { %>
|
2018-03-01 06:08:42 +00:00
|
|
|
let files = require.context('@/<%= dir.middleware %>', false, /^\.\/(?!<%= ignorePrefix %>)[^.]+\.(<%= extensions %>)$/)
|
2017-02-03 14:09:27 +00:00
|
|
|
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) {
|
2018-01-04 17:10:17 +00:00
|
|
|
let name = filename.replace(/^\.\//, '').replace(/\.(<%= extensions %>)$/, '')
|
2017-02-03 14:09:27 +00:00
|
|
|
middleware[name] = getModule(filename)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default middleware
|
|
|
|
<% } else { %>export default {}<% } %>
|