middleware.js 566 B

123456789101112
  1. const middleware = {}
  2. <%= isTest ? '/* eslint-disable dot-notation */' : '' %>
  3. <% for (const m of middleware) {
  4. // TODO: remove duplicate logic in v3 (see builder.resolveMiddleware)
  5. const name = m.name || m.src.replace(new RegExp(`\\.(${extensions})$`), '')
  6. const dst = m.dst || relativeToBuild(srcDir, dir.middleware, m.src)
  7. %>
  8. middleware['<%= name %>'] = require('<%= dst %>')
  9. middleware['<%= name %>'] = middleware['<%= name %>'].default || middleware['<%= name %>']
  10. <% } %>
  11. <%= isTest ? '/* eslint-enable dot-notation */' : '' %>
  12. export default middleware