How to use the @cardstack/di.Container function in @cardstack/di

To help you get started, we’ve selected a few @cardstack/di examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cardstack / cardstack / packages / hub / main.js View on Github external
);

  if (typeof opts.seeds === 'function') {
    registry.register('config:initial-models', opts.seeds);
  } else {
    registry.register('config:initial-models', () => []);
  }

  if (process.env.PROFILE_MEMORY_SEC) {
    setInterval(
      () => writeSnapshot((err, filename) => log.info(`heap dump written to ${filename}`)),
      process.env.PROFILE_MEMORY_SEC * 1000
    );
  }

  let container = new Container(registry);

  // in the test suite we want more deterministic control of when
  // indexing happens
  if (!opts.disableAutomaticIndexing) {
    await container.lookup(`plugin-client:${require.resolve('@cardstack/pgsearch/client')}`).ensureDatabaseSetup();
    startIndexing(opts.environment, container); // dont await boot-time indexing, invalidation logic has our back
  }

  // this registration pattern is how we make broccoli wait for our
  // asynchronous startup stuff before running the first build.
  if (opts.broccoliConnector) {
    opts.broccoliConnector.setSource(container.lookup('hub:code-generators'));
  }

  return container;
}
github cardstack / cardstack / packages / hub / container-stuff / create-plugin-services.js View on Github external
module.exports = async function createPluginServices() {
  let registry = new Registry();

  registry.register('config:project', {
    path: '/Users/aaron/dev/cardstack/packages/models',
    allowDevDependencies: true
  });

  let container = new Container(registry);

  let loader = container.lookup('hub:plugin-loader');

  let pluginConfigs = loadSeedModels('/Users/aaron/dev/cardstack/packages/models/tests/dummy/cardstack/seeds/development').filter(model => model.type === 'plugin-configs');

  let plugins = await loader.activePlugins(pluginConfigs);

  let services = plugins.listAll('docker-services').map(s => plugins.lookupFeature('docker-services', s));

  return Promise.all(services.map(function(service_config) {
    return createService([
      '--name', service_config.name,
      service_config.image
    ], {stdio: 'inherit'});
  }));

@cardstack/di

dependency injection support for cardstack hub

MIT
Latest version published 1 year ago

Package Health Score

58 / 100
Full package analysis

Similar packages