const router = require('express').Router()
const fs = require('fs')
const logger = require('../../config/logger')

const appsRouters = []
const subApps = fs.readdirSync(__dirname)

subApps.forEach(subAppDir => {
  try {
    const subApp = require(`./${subAppDir}`)

    if (subApp.mountpath) {
      appsRouters.push(router.use(subApp.mountpath, subApp.router))
    } else if (subApp.router) {
      appsRouters.push(router.use(subApp.router))
    } else {
      appsRouters.push(() => {}) // add dummy router as fallback
    }
  } catch (err) {
    logger.warn(err.message)
  }
})

module.exports = appsRouters

@@ -478,48 +478,34 @@
 sh((
-) =%3E %7B%7D) // add dummy router as fallback
+req, res, next) =%3E next())
 %0A   

Allow empty router to pass to next middleware