express-load-routers
v1.5.0
Published
Loads express 4.x routers from directory recursively
Downloads
11
Readme
express-load-routers
Load routers from specific folders for Express 4.x
Install
npm i express-load-routers
Usage
const path = require('path');
const express = require('express');
const loadRouters = require('express-load-routers');
const app = express();
app.use(loadRouters('./routes'));
Options
loadRouters(directory, options);
option | type | default | decription ---------------|-------|---------|------------ exclude | Array | ['_*'] | This array contain match patterns that will excludes.
Router
ex) routes/sample.js -> http://localhost/sample/
module.exports = router = require('express').Router();
router.get('/', (req, res, next)=>{
res.send('OK');
});
ex) routes/camel/index.js -> http://localhost/camel/
ex) routes/one/two.js -> http://localhost/one/two/three/
module.exports = router = require('express').Router();
router.get('/three', (req, res, next)=>{
res.send('OK');
});
License
MIT License.