aers-custom
v1.4.8
Published
Express autoload router
Downloads
96
Maintainers
Readme
aers-custom
Autoload Express Routers (custom package)
You can see spesific detail "README" how to use it from previous package at https://www.npmjs.com/package/express-autoload-router
New Custom Features
- Adding params on routes controller.
- Check available routes with a simple way.
Example
--- How to use it on controllers
exports.show = {
method: ['GET'],
params: [':id'],
handler(req, res) {
res.status(200).json({
info: `id = ${req.params.id}`
}),
}
}--- Check available routes
You can set to true on third parameter on loadRouter variable and it will print it to the console once after server is running.
const loadRouter = require('aers-custom')
loadRouter(app, '/api/', path.join(__dirname, '../api/controllers'), true);
// expect output:
// endpoint uri: [ GET ] /blog
// endpoint uri: [ GET ] /blog/show/:id
// endpoint uri: [ POST ] /blog/store
// endpoint uri: [ PATCH ] /blog/update/:id
// endpoint uri: [ DELETE ] /blog/delete/:idThanks
Special thanks to ~imcooder who made this package before.
