express-auto-path-router
v1.3.1
Published
Auto path router serving middleware for express
Downloads
2
Readme
express-auto-path-router
Express auto path middleware, no need to write every router. The rule like this:
GET /a
-> /GET/a/index.js
POST /a
-> /POST/a/index.js
Installation
$ npm install express-auto-path-router
API
const Express = require('express');
const app = Express();
app.use(require('express-auto-path-router')(root));
root
root directory string. nothing above this root directory can be served
Example
const expressAutoPathRouter = require('express-auto-path-router');
const Express = require('express');
const app = new Express();
app.use(expressAutoPathRouter('./mock/'));
You can write the index.js like this:
module.exports = function (req, res, next) {
return {
status: 0,
statusInfo: 'AAA',
data: {
}
};
};
Demo
npm install
npm run demo
Test
npm install
npm run test
License
MIT