Nationwide Polamorous Matrimony

    bozz-load-dir

    1.0.2 • Public • Published

    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 !

    Keywords

    none

    Install

    npm i bozz-load-dir

    DownloadsWeekly Downloads

    0

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • fleebz