simple-route-loader
v0.3.1
Published
A simple module to autoload ExpressJS routers.
Downloads
20
Readme
Simple Route Loader
A simple module to autoload ExpressJS routers.
Installation
npm i simple-route-loader --save
Example
Simply require
the module and pass in your Express app..
require('simple-route-loader')(app);
and create a router..
'use strict';
var router = module.exports = require('express').Router();
router.route('/')
.get(function (req, res) {
res.send('Look, ma!');
});
Configuration
The module accepts a configuration object as an optional second parameter.
require('simple-route-loader')(app, {
dir: __dirname
});
Options
dir — Change the folder to look for routers
- Can be a String or an Array. If a String is passed, it is cast to an Array;
- Defaults to the current working directory.
file — Change the name of files to load
- Can be a String or an Array. If a String is passed, it is cast to an Array;
- Defaults to the router.js.
preserveTree — Use the actual file path of the router
- Can be a Boolean or a String. If a String is passed, it is cast to a Boolean;
- Defaults to true.
Told you it's simple.