From d680bf4c5e0530e90cf817e07a048f69886c7c04 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Wed, 11 Dec 2019 12:17:29 +0100 Subject: [PATCH] add subdirectory option --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 58b225b..75c13b3 100644 --- a/index.js +++ b/index.js @@ -8,11 +8,11 @@ const path = require('path'); * @param {string} modulefolder * @param {any} opts object to pass to the handlers (for example database access) */ -module.exports = function (app, modulefolder, opts) { +module.exports = function (app, modulefolder, opts = {}, subdir = '') { for (const f of fs.readdirSync(modulefolder)) { const regex = /(.*?)-(.*?)\.js/; let [, method, url] = regex.exec(f); - url = '/' + url + '/'; + url = '/' + subdir + '/' + url + '/'; url = url .replace(/^\/root/i, '/') .replace(/\./g, '/')