2.4.0 • Published 6 years ago
restify-route-loader v2.4.0
restify-route-loader
A module to automate route loading for Restify.
Installation
npm i restify-route-loader -S
Usage
import restify from 'restify';
import routeLoader from 'restify-route-loader';
const server = restify.createServer();
server.use(routeLoader(server));
server.listen(port, () => {});
Folder Structure
-/routes
--get.js
--/aboutus
---get.js
---post.js
-/routes
--get-1.0.0.js
--get-1.1.0.js
--/aboutus
---get.js
---post.js
File Setup
If the file is just the verb without the version, include the version within the file
exports.default = [
{
version: "1.0.0",
controller: function(req, res, next) {
return res.send('Hello World')
}
}
]
Configuration
The module accepts a configuration object as an optional second parameter.
server.use(routeLoader(server, {
routes: path.join(__dirname, 'routes')
}));
Options
routes — Change the folder to look for routes
- Defaults to
routes/
inside the current working directory
verbs — Enable loading of additional HTTP methods
- Must be supported by Restify
- Defaults to
get
,post
,del
,put
TODO
- Update (create) documentation
- Add build process