1.0.1 • Published 7 years ago
exhooks v1.0.1
ExHooks
lightweight nodejs library that allows you to register whichever hook you want, and you can issue it whenever you want, as easy as say hello.
Install.
- npm install --save exhooks
- npm install exhooks
- yarn add exhooks
Usage.
var exhooks = require('exhooks');
var express = require('express');
var app = express();
var hook_events = [
{
eventName: 'logout',
eventFunc: (param) => { console.log('bye bye =) ' + param) }
}
]
app.use(exhooks(hook_events));
app.get('/logout', (req, res) => {
.
.
.
req.hooks.logout(1);
res.status(200).json({
message: "ok"
})
});
app.listen(3000);
What you cannot do.
- You cannot register hooks that contains any number
- You cannot register hooks that contains any special character.
- You cannot register hooks that are duplicated.