View on GitHub

coredi

Dependency Injection library for Node.js and Browser

Getting started

CoreDI actively uses JS promises and async/await.

How install CoreDI:

npm install @empla/coredi

First, we need create a container from schema.

const coredi = require('@empla/coredi');

coredi({
    app: {
        loaders: [
            {
                name: 'myservice',
                async create(container) {
                    return myServiceObject;
                },
            },
        ],
    },
}, 'app').then(function(container) {
    const myservice = container('myservice');  
    // myservice is myServiceObject ...
});