0.16.0 • Published 10 months ago

anatomic v0.16.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

anatomic

A (very) minimal dependency injection library.

This is a fork of systemic, with changes for enhanced minimalism.

tl;dr

Define the system

// system.js
const System = require('anatomic');
const config = require('./components/config');
const logger = require('./components/logger');
const postgres = require('./components/postgres');

module.exports = () => System({
  config: { init: config() },
  logger: { init: logger(), dependsOn: 'config' },
  postgres: {
    primary:   { init: postgres(), dependsOn: ['config', 'logger'] },
    secondary: { init: postgres(), dependsOn: ['config', 'logger']}
  }
});

Run the system

const System = require('./system');

const events = { SIGTERM: 0, SIGINT: 0, unhandledRejection: 1, error: 1 };

async function main() {
  const system = System();
  const { config, postgres, logger } = await system.start();

  console.log('System has started. Press CTRL+C to stop');

  Object.keys(events).forEach((name) => {
    process.on(name, async () => {
      await system.stop();
      console.log('System has stopped');
      process.exit(events[name]);
    });
  });
}

main();
0.15.0

10 months ago

0.16.0

10 months ago

0.14.0

11 months ago

0.12.0

11 months ago

0.13.0

11 months ago

0.13.1

11 months ago

0.11.1

12 months ago

0.10.0

1 year ago

0.11.0

1 year ago

0.10.1

1 year ago

0.9.0

1 year ago

0.7.2

1 year ago

0.8.0

1 year ago

0.7.1

1 year ago

0.5.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.3.0

2 years ago

0.4.0

2 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.0

3 years ago