function createStaticIndex(indexNameToDir) {
  return (req, res) => {
    if (req.method != 'GET') {
      return sendError(res, 405, `Method is not allowed`)
    }

    const parts = req.path.substring(1).split('/').map(decodeURI)
    const indexName = parts.shift()
    const dir = indexNameToDir[indexName]

    if (!dir || !parts.length) {
      return sendError(res, 404, `File not found`)
    }

    const file = path.resolve(dir, ...parts)
    const filename = parts.join('/')
    stat(file, (err, stats) => {
      if (err || !stats.isFile()) {
        return sendError(res, 404, `File ${filename} for index ${indexName} not found`)
      }
      log.trace({indexName, dir, filename}, `Send original file ${filename} from index ${indexName}`)
      return res.sendFile(file)
    })
  }
}
@type {{ndex: string, dir: string, offline?: boolean, downloadable?: boolean}[]}