
// Configure middleware. (Can be re-generated.)
<%- tplTsOnly([`import { App } from '../app.interface'${sc}`, '', '']) -%>
<%# -%>
<%# --- forEach-1 starts below. -%>
<% Object.keys(specs.middlewares || {}).sort().forEach(name => {
  __temp = specs.middlewares[name];
-%>
<%- tplImports(__temp.camel, `./${__temp.kebab}`) %>
<% }) -%>
<%# --- forEach-1 ends above. -%>
<%- insertFragment('imports') %>
<%- insertFragment('init') %>

// <%- lintDisableNextLineUnused %>
<%- tplModuleExports(null, 'function (app) {', 'function (app: App) {') %>
  <%- insertFragment('func_init') %>
  // Add your custom middleware here. Remember that
  // in Express, the order matters.
<%# -%>
<%# --- forEach-2 starts below. -%>
<% __temp0 = [];-%>
<% Object.keys(specs.middlewares || {}).forEach(name => {
  __temp = specs.middlewares[name];
  __temp0.push(
    `  app.use(${__temp.path !== '*' ? `'${__temp.path}', ` : ''}${__temp.camel}())${sc}`
  );
}) -%>
<%# --- forEach-2 ends above. -%>
<%# -%>
<%# --- if-2 starts below. -%>
<% if (__temp0.length) { -%>
  // Your middleware should include:
<%# -%>
<%# --- forEach-3 starts below. -%>
<% __temp0.forEach(line => { -%>
  // <%- line %>
<% }) -%>
<%# --- forEach-3 ends above. -%>
<% } -%>
<%# --- if-2 ends above. -%>
  <%- insertFragment('middleware', __temp0.length ? __temp0 : null) %>
  <%- insertFragment('func_return') %>
}<%- sc %>

<%- insertFragment('exports') %>
<%- `${tplExport('moduleExports')}${sc}` %>

<%- insertFragment('funcs') %>
<%- insertFragment('end') %>
