1.1.3 • Published 4 years ago

laconias v1.1.3

Weekly downloads
57
License
MIT
Repository
github
Last release
4 years ago

laconias

requirejs like service for laconia

npm npm Codecov branch Commitizen friendly styled with prettier Code of Conduct Roadmap

Why?

Every time you use require you make it tightly coupled with required library. This isn't good for tests and SOLID principles.

With this you can `require' things and inject/mock them when testing

Installation

npm install --save laconias

Usage

// services/print.js

module.exports = laconiaContext => data => console.log(data);

// index.js

const laconia require('@laconia/core');
const laconias = require('laconias');

const app = (event, {
  S: { print },
  services: { print: print2 },
}) => {
  // do something with service;
  print(event);
  print2(event)
};

const S = laconias(`${__dirname}/services`)

exports.handler = laconia(app)
  .register(S)
  //.register('otherServices', laconias(`${__dirname}/otherPath`).factory);
  .register('services', S.factory);

FAQ

Should you use it?

Good question, the main feature of Laconia is to be a Micro dependency injection framework, some DI frameworks recommends to do not use it for things like require external library.

My point is that you may use it for service creation.

How use it with Tree shaking?

You couldn't, since your dependency are loaded dynamically. Isn't not impossible but not implemented yet.

Related

Contributors

Thanks goes to these people (emoji key):

hugosenari💻 📖 🚇

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT © hugosenari

1.1.3

4 years ago

1.1.2

4 years ago

1.0.1

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago