services-stack

1.2.0 • Public • Published

services-stack

Node.js Version NPM version build status Dependency Status Coverage Status

Stack recursively services file on array. You can stack function, object or class.

installation

npm install services-stack

Usage

if services file is a function, context will be automatically inject.

if services file is a class or object, you need to pass manualy the context, via new for example

context is an object. It contains a service() function. this allow to get services from another service.

models/
    contacts.js // object
    other.js // function
    user/user.js // class
    ...
const context = {
    db : db,
    config : config,
    ...
};
 
const services = require('services-stack')({
    path : './models'
    context: context
});
 
const contact = services.get('contacts');

Example of a service.

module.exports = ctx => {
    const db = ctx.db;
    const contacts = ctx.service('contacts');
 
    return {
        ...
    }
}

Package Sidebar

Install

npm i services-stack

Weekly Downloads

3

Version

1.2.0

License

MIT

Last publish

Collaborators

  • menems