A module to automate route loading for Restify.
npm i restify-route-loader -S
import restify from 'restify';
import routeLoader from 'restify-route-loader';
const server = restify.createServer();
server.use(routeLoader(server));
server.listen(port, () => {});
-/routes
--get.js
--/aboutus
---get.js
---post.js
-/routes
--get-1.0.0.js
--get-1.1.0.js
--/aboutus
---get.js
---post.js
If the file is just the verb without the version, include the version within the file.
export default [
{
version: '1.0.0',
controller: function (req, res, next) {
return res.send('Hello World');
}
}
];
The module accepts a configuration object as an optional second parameter.
server.use(routeLoader(server, {
routes: path.join(__dirname, 'routes')
}));
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
- Update (create) documentation
- Add build process