How to use the @tsed/di.GlobalProviders.createRegistry function in @tsed/di

To help you get started, we’ve selected a few @tsed/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 TypedProject / ts-express-decorators / packages / common / src / mvc / registries / ControllerRegistry.ts View on Github external
import {GlobalProviders, ProviderType, TypedProvidersRegistry} from "@tsed/di";
import {ControllerProvider} from "../models/ControllerProvider";
import {ExpressRouter} from "../services/ExpressRouter";

// tslint:disable-next-line: variable-name
export const ControllerRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider, {
  injectable: false,

  onInvoke(provider: ControllerProvider, locals: any) {
    locals.set(ExpressRouter, provider.router);
  }
});
github TypedProject / ts-express-decorators / packages / common / src / mvc / registries / MiddlewareRegistry.ts View on Github external
import {GlobalProviders, Provider, ProviderType, TypedProvidersRegistry} from "@tsed/di";

/**
 *
 * @type {Registry, Provider>}
 */
// tslint:disable-next-line: variable-name
export const MiddlewareRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(ProviderType.MIDDLEWARE, Provider, {
  injectable: true,
  buildable: true
});
/**
 * Add a new middleware in the `ProviderRegistry`. This middleware will be built when `InjectorService` will be loaded.
 *
 * #### Example
 *
 * ```typescript
 * import {registerMiddleware, InjectorService} from "@tsed/common";
 *
 * export default class FooMiddleware {
 *     constructor(){}
 *     use() {
 *         return "test";
 *     }
github TypedProject / ts-express-decorators / packages / common / src / converters / registries / ConverterRegistries.ts View on Github external
import {Provider, ProviderType, TypedProvidersRegistry, GlobalProviders} from "@tsed/di";

/**
 * Converter Registry.
 * @type {Registry, IProvider>}
 */
// tslint:disable-next-line: variable-name
export const ConverterRegistry: TypedProvidersRegistry = GlobalProviders.createRegistry(ProviderType.CONVERTER, Provider, {
  injectable: true
});
/**
 * Add a new converter in the `ProviderRegistry`. This converter will be built when `InjectorService` will be loaded.
 *
 * #### Example
 *
 * ```typescript
 * import {registerConverter, InjectorService} from "@tsed/common";
 *
 * export default class MyConverter {
 *     constructor(){}
 *     serialize() {
 *         return "test";
 *     }
 * }