How to use the @cardstack/hub/main.wireItUp function in @cardstack/hub

To help you get started, we’ve selected a few @cardstack/hub 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 / node-tests / support.js View on Github external
params: { repo: repoPath }
        })
    );

  factory.addResource('plugin-configs')
    .withAttributes({ module: '@cardstack/git' });

  factory.addResource('grants')
    .withAttributes({
      mayCreateResource: true,
      mayUpdateResource: true,
      mayDeleteResource: true,
      mayWriteField: true
    }).withRelated('who', factory.addResource('groups', user.id));

  let container = await wireItUp(crypto.randomBytes(32), factory.getModels(), false);

  let writers = container.lookup('hub:writers');

  for (let model of inDependencyOrder(initialModels)) {
    // TODO: this one-by-one creation is still slower than is nice for
    // tests -- each time we write a schema model it invalidates the
    // schema cache, which needs to get rebuilt before we can write
    // the next one. Which also requires us to use inDependencyOrder,
    // which is kinda lame.
    //
    // On the other hand, this is a high-quality test of our ability
    // to build up the entire state in the same way an end user would
    // via JSONAPI requests. If we optimize this away, we should also
    // add some tests like that that are similarly comprehensive.
    let response = await writers.create('master', user.data, model.type, model);
    head = response.meta.version;
github cardstack / cardstack / packages / test-support / env.js View on Github external
mayLogin: true,
      })
      .withRelated('who', [{ type: user.data.type, id: user.data.id }]);

    let models = factory.getModels();
    let [foreignInitialModels, ephemeralInitialModels] = partitionInitialModels(models);

    opts.disableAutomaticIndexing = true;
    opts.environment = 'test';
    opts.seeds = () => ephemeralInitialModels;

    opts.pgBossConfig = opts.pgBossConfig || {
      newJobCheckInterval: 100, // set to minimum to speed up tests
    };

    container = await wireItUp(projectDir, crypto.randomBytes(32), defaultDataSource.getModels(), opts);
    if (foreignInitialModels.length) {
      await loadSeeds(container, foreignInitialModels);
    } else {
      await container.lookup('hub:indexers').update({ forceRefresh: true });
    }

    let ephemeralStorage = await container.lookup(`plugin-services:${require.resolve('@cardstack/ephemeral/service')}`);
    let searchers = await container.lookup(`hub:searchers`);
    await ephemeralStorage.validateModels(models, async (type, id) => {
      let result;
      try {
        result = await searchers.get(Session.INTERNAL_PRIVILEGED, 'local-hub', type, id);
      } catch (err) {
        if (err.status !== 404) {
          throw err;
        }

@cardstack/hub

Stock API server for the Cardstack tech stack.

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages