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 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);
};

2
package-lock.json generated
View File

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

View File

@ -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": {