How to use the @cardstack/hub/main.loadSeeds 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 / test-support / env.js View on Github external
.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