2017-02-03 14:09:27 +00:00
|
|
|
<% if (middleware) { %>
|
2017-06-29 16:36:22 +00:00
|
|
|
let files = require.context('@/middleware', false, /^\.\/.*\.(js|ts)$/)
|
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) {
|
2017-05-05 12:07:54 +00:00
|
|
|
let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '')
|
2017-02-03 14:09:27 +00:00
|
|
|
middleware[name] = getModule(filename)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default middleware
|
|
|
|
<% } else { %>export default {}<% } %>
|