Skip to content

weview/bozz-load-dir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 !

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published