restify-route-map
v1.0.2
Published
Dynamically attach routes given a source directory
Downloads
4
Readme
restify-route-map
Dynamically attach routes given a source directory.
Install
npm i restify-route-map -S
Usage
// Route File eq. user.js
// A function wrapper is required for each route file
module.exports = function (server) {
server.get('/', (req, res) => {
// Handle request
});
server.post('/', (req, res) => {
// Handle request
});
};
// File where app is initialize eq. app.js
// Import
const restifyRouteMap = require('restify-route-map');
const server = restify.createServer();
// Initialize restify plugins
const options = {
directory: 'controllers',
pattern: '**/*.js'
}
restifyRouteMap(server, options);
Options
- baseDir - base directory, default value
caller directory
- directory - source directory, default value
routes
- pattern - files to match, uses glob, default value
**/*.js
License
MIT