2017-02-03 14:09:27 +00:00
|
|
|
<% if (middleware) { %>
|
2018-10-12 22:31:19 +00:00
|
|
|
const files = require.context('@/<%= dir.middleware %>', false, /^\.\/(?!<%= ignorePrefix %>)[^.]+\.(<%= extensions %>)$/)
|
|
|
|
const filenames = files.keys()
|
2017-02-03 14:09:27 +00:00
|
|
|
|
|
|
|
function getModule (filename) {
|
2018-10-12 22:31:19 +00:00
|
|
|
const file = files(filename)
|
|
|
|
return file.default || file
|
2017-02-03 14:09:27 +00:00
|
|
|
}
|
2018-10-12 22:31:19 +00:00
|
|
|
const middleware = {}
|
2017-02-03 14:09:27 +00:00
|
|
|
|
|
|
|
// Generate the middleware
|
2018-10-12 22:31:19 +00:00
|
|
|
for (const filename of filenames) {
|
|
|
|
const name = filename.replace(/^\.\//, '').replace(/\.(<%= extensions %>)$/, '')
|
2017-02-03 14:09:27 +00:00
|
|
|
middleware[name] = getModule(filename)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default middleware
|
|
|
|
<% } else { %>export default {}<% } %>
|