bozz-load-dir
v1.0.2
Published
Be able to load a dir with bozz based files
Downloads
2
Readme
Bozz load dir
Plugin for Bozz.
Principle
This plugin loads all requests
and events
files found in the bozz
directory of your project.
Installation
Assuming you already have bozz
installed in your project.
yarn add bozz-load-dir
or
npm install --save bozz-load-dir
Bozz directory and files
MyProject
|-- node_modules/
|-- package.json
|-- bozz
|-- user.requests.js
|-- user.events.js
|-- book.events.js
user.events.js (Object version)
const UserSession = require(`./model/UserSession`);
module.exports = {
`user:loggedIn` : UserSession.start,
`user:loggedOut` : UserSession.end,
};
user.events.js (Method version)
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),
});
Usage
const bozz = require(`bozz`);
const bozzLoadDir = require(`bozz-load-dir`);
const ms = bozz.createMs();
ms.use(bozzLoadDir);
That's all. Enjoy !