eslint
This commit is contained in:
parent
55f631de02
commit
3c5bf74581
11
index.js
11
index.js
@ -11,9 +11,16 @@ module.exports = function (app, modulefolder, opts) {
|
||||
for (const f of fs.readdirSync(modulefolder)) {
|
||||
const regex = /(.*?)-(.*?)\.js/;
|
||||
let [, method, url] = regex.exec(f);
|
||||
url = '/' + url.replace(/^root/i, '').replace(/\./g, '/').replace(/\/+/g, '/');
|
||||
url =
|
||||
'/' +
|
||||
url
|
||||
.replace(/^root/i, '')
|
||||
.replace(/\./g, '/')
|
||||
.replace(/\/+/g, '/');
|
||||
|
||||
const handler = require(('./' + modulefolder + '/' + f).replace(/\/\.\//g, '/').replace(/\/+/g, '/'));
|
||||
const handler = require(('./' + modulefolder + '/' + f)
|
||||
.replace(/\/\.\//g, '/')
|
||||
.replace(/\/+/g, '/'));
|
||||
const func = (req, res, next) => {
|
||||
handler(req, res, next, opts);
|
||||
};
|
||||
|
@ -25,6 +25,12 @@ const mock = {
|
||||
describe('requestor', () => {
|
||||
it('should detect all requests on root', () => {
|
||||
requestor(mock, './test/onroot', {});
|
||||
expect(mock.registered).to.have.all.keys(['post-/', 'get-/', 'put-/', 'delete-/', 'all-/']);
|
||||
expect(mock.registered).to.have.all.keys([
|
||||
'post-/',
|
||||
'get-/',
|
||||
'put-/',
|
||||
'delete-/',
|
||||
'all-/'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user