Skip to content

menems/services-stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 {
        ...
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published