Cartola
Dependency Container for universal Services using the Functional Factory Pattern.
Why you should use Cartola?
- Dependency container helps to maintain the interoperability in your system.
- Service's creation is lazy by default.
- You need to import the service creator in order to use, so is easy to find it's source / code / file, it's explicit.
Install
npm install --save cartola
or
yarn add cartola
Basic usage:
// @file: /services/cmsApi.js // Universal Service.const cmsApi = { const request = // Superagent middleware. request return request}
// @file: /index.js // Lazy service creation of your REST client.container { // Api client is created for the first time. const api = container // Get the content through the service. const content = api} { // Api client is already created. const api = container // Get the content through the service. const content = api} // Here's where you inject the container.
Development setup:
Install
git clone https://github.com/choko-org/cartola.gityarn
Build
yarn build
Build and Run the tests
yarn test