diff --git a/index.js b/index.js index 39f61b5..58b225b 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ const fs = require('fs'); +const path = require('path'); /** * Load all request handlers in the given folder @@ -17,9 +18,7 @@ module.exports = function (app, modulefolder, opts) { .replace(/\./g, '/') .replace(/\/+/g, '/'); - const handler = require(('./' + modulefolder + '/' + f) - .replace(/\/\.\//g, '/') - .replace(/\/+/g, '/')); + const handler = require(path.join(process.cwd(), modulefolder, f)); const func = (req, res, next) => { handler(req, res, next, opts); }; diff --git a/package-lock.json b/package-lock.json index efd409c..948fc28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "requestor", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 443885a..77e46b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@scode/requestor", - "version": "1.0.1", + "version": "1.0.2", "description": "Split express paths into individual files to make api programming more structured", "main": "index.js", "scripts": {