How to use the @loopback/core.BindingScope.TRANSIENT function in @loopback/core

To help you get started, we’ve selected a few @loopback/core 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 strongloop / loopback-next / packages / boot / src / __tests__ / integration / interceptor.booter.integration.ts View on Github external
it('boots non-global interceptors when app.boot() is called', async () => {
    const expectedBinding = {
      key: `interceptors.myInterceptor`,
      tags: [
        ContextTags.PROVIDER,
        ContextTags.TYPE,
        ContextTags.NAMESPACE,
        ContextTags.NAME,
      ],
      scope: BindingScope.TRANSIENT,
    };

    await app.boot();

    const binding = app.getBinding('interceptors.myInterceptor');
    expect({
      key: binding.key,
      tags: binding.tagNames,
      scope: binding.scope,
    }).to.eql(expectedBinding);
  });
github strongloop / loopback-next / packages / boot / src / __tests__ / integration / interceptor.booter.integration.ts View on Github external
it('boots global interceptors when app.boot() is called', async () => {
    const expectedBinding = {
      key: `${GLOBAL_INTERCEPTOR_NAMESPACE}.myGlobalInterceptor`,
      tags: [
        ContextTags.PROVIDER,
        ContextTags.TYPE,
        ContextTags.GLOBAL_INTERCEPTOR,
        ContextTags.NAMESPACE,
        ContextTags.GLOBAL_INTERCEPTOR_GROUP,
        ContextTags.NAME,
      ],
      scope: BindingScope.TRANSIENT,
    };

    await app.boot();

    const bindings = app
      .findByTag(ContextTags.GLOBAL_INTERCEPTOR)
      .map(b => ({key: b.key, tags: b.tagNames, scope: b.scope}));
    expect(bindings).to.containEql(expectedBinding);
  });
github strongloop / loopback-next / packages / service-proxy / src / __tests__ / unit / mixin / service.mixin.unit.ts View on Github external
async function expectGeocoderToBeBound(myApp: Application) {
    const boundServices = myApp.find('services.*').map(b => b.key);
    expect(boundServices).to.containEql('services.GeocoderService');
    const binding = myApp.getBinding('services.GeocoderService');
    expect(binding.scope).to.equal(BindingScope.TRANSIENT);
    const serviceInstance1 = await myApp.get('services.GeocoderService');
    expect(serviceInstance1).to.be.instanceOf(DummyGeocoder);
    const serviceInstance2 = await myApp.get('services.GeocoderService');
    expect(serviceInstance2).to.not.be.equal(serviceInstance1);
  }
github strongloop / loopback-next / packages / repository / src / __tests__ / unit / mixins / repository.mixin.unit.ts View on Github external
function expectNoteRepoToBeBound(myApp: Application) {
    const boundRepositories = myApp.find('repositories.*').map(b => b.key);
    expect(boundRepositories).to.containEql('repositories.NoteRepo');
    const binding = myApp.getBinding('repositories.NoteRepo');
    expect(binding.scope).to.equal(BindingScope.TRANSIENT);
    const repoInstance = myApp.getSync('repositories.NoteRepo');
    expect(repoInstance).to.be.instanceOf(NoteRepo);
  }