1.3.1 • Published 7 years ago

express-auto-path-router v1.3.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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