require absolute

This commit is contained in:
Timo Hocker 2019-12-11 11:27:35 +01:00
parent 810d8107ae
commit 6d6dfe1991
3 changed files with 4 additions and 5 deletions

View File

@ -1,4 +1,5 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path');
/** /**
* Load all request handlers in the given folder * Load all request handlers in the given folder
@ -17,9 +18,7 @@ module.exports = function (app, modulefolder, opts) {
.replace(/\./g, '/') .replace(/\./g, '/')
.replace(/\/+/g, '/'); .replace(/\/+/g, '/');
const handler = require(('./' + modulefolder + '/' + f) const handler = require(path.join(process.cwd(), modulefolder, f));
.replace(/\/\.\//g, '/')
.replace(/\/+/g, '/'));
const func = (req, res, next) => { const func = (req, res, next) => {
handler(req, res, next, opts); handler(req, res, next, opts);
}; };

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "requestor", "name": "requestor",
"version": "1.0.1", "version": "1.0.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@scode/requestor", "name": "@scode/requestor",
"version": "1.0.1", "version": "1.0.2",
"description": "Split express paths into individual files to make api programming more structured", "description": "Split express paths into individual files to make api programming more structured",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {