Plugin for Bozz.
This plugin loads all requests
and events
files found in the bozz
directory of your project.
Assuming you already have bozz
installed in your project.
yarn add bozz-load-dir
or
npm install --save bozz-load-dir
MyProject
|-- node_modules/
|-- package.json
|-- bozz
|-- user.requests.js
|-- user.events.js
|-- book.events.js
const UserSession = require(`./model/UserSession`);
module.exports = {
`user:loggedIn` : UserSession.start,
`user:loggedOut` : UserSession.end,
};
When you export a method insteadof an object, you have access to the ms
instance in this method :
module.exports = ms => ({
`user:loggedIn` : user => ms.request(`user-session:start`, user),
`user:loggedOut` : user => ms.request(`user-session:end`, user),
});
const bozz = require(`bozz`);
const bozzLoadDir = require(`bozz-load-dir`);
const ms = bozz.createMs();
ms.use(bozzLoadDir);
That's all. Enjoy !