ServiceManager
A pretty simple service manager.
Install
ServiceManager
is hosted on npm:
npm install simple-service-manager
const ServiceManager = require('simple-service-manager');
Usage
ServiceManager
allows you to define application wide service objects. Services are defined using a factories config:
ServiceManager; const serviceManager = ServiceManager;const logger = serviceManager; logger; // logs to /var/log/my_app.log
Service factories have access to the service manager, making it easy to wire components together:
ServiceManager; const serviceManager = ServiceManager;const myComponent = serviceManager; myComponent;// logs "component was updated!" to /var/log/my_app.log
Test Mocks
ServiceManager
allows you to mock out services for testing. For example, let's say we want to mock out a database service in a test.
const FooModel = ;const serviceManager = ;const sinon = ;const assert = ; ;