Skip to content

xiaoqiang-zhao/express-auto-path-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Express auto path middleware, no need to write every router.

Resources

License

Stars

Watchers

Forks

Packages

No packages published