eslint
This commit is contained in:
		
							
								
								
									
										11
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								index.js
									
									
									
									
									
								
							| @@ -11,9 +11,16 @@ module.exports = function (app, modulefolder, opts) { | |||||||
|   for (const f of fs.readdirSync(modulefolder)) { |   for (const f of fs.readdirSync(modulefolder)) { | ||||||
|     const regex = /(.*?)-(.*?)\.js/; |     const regex = /(.*?)-(.*?)\.js/; | ||||||
|     let [, method, url] = regex.exec(f); |     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) => { |     const func = (req, res, next) => { | ||||||
|       handler(req, res, next, opts); |       handler(req, res, next, opts); | ||||||
|     }; |     }; | ||||||
|   | |||||||
| @@ -25,6 +25,12 @@ const mock = { | |||||||
| describe('requestor', () => { | describe('requestor', () => { | ||||||
|   it('should detect all requests on root', () => { |   it('should detect all requests on root', () => { | ||||||
|     requestor(mock, './test/onroot', {}); |     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