How to use the @tsed/di.Injectable 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 / config / services / ServerSettingsService.ts View on Github external
const rootDir = process.cwd();
/**
 * @deprecated
 */
export let globalServerSettings: ServerSettingsService;
/**
 * @deprecated
 */
// tslint:disable-next-line: variable-name
export let GlobalServerSettings: ServerSettingsService;

/**
 * `ServerSettingsService` contains all information about [ServerLoader](/api/common/server/components/ServerLoader.md) configuration.
 */
@Injectable({
  scope: ProviderScope.SINGLETON,
  global: true
})
export class ServerSettingsService implements IServerSettings, IDISettings {
  protected map = new Map();

  constructor() {
    this.rootDir = rootDir;
    this.env = (process.env.NODE_ENV as Env) || Env.DEV;
    this.port = 8080;
    this.httpsPort = 8000;
    this.version = "1.0.0";
    this.uploadDir = "${rootDir}/uploads";
    this.controllerScope = ProviderScope.SINGLETON;
    this.logger = {
      debug: false,
github TypedProject / ts-express-decorators / packages / common / src / mvc / services / ControllerService.ts View on Github external
import {Deprecated, ProxyMap, Type} from "@tsed/core";
import {Configuration, Injectable, InjectorService, ProviderScope, ProviderType} from "@tsed/di";
import {ControllerProvider} from "../models/ControllerProvider";
import {ControllerRegistry} from "../registries/ControllerRegistry";
import {IRouteController, RouteService} from "./RouteService";

/**
 * @private
 * @deprecated
 */
@Injectable({
  scope: ProviderScope.SINGLETON,
  global: true
})
export class ControllerService extends ProxyMap | any, ControllerProvider> {
  constructor(
    private injectorService: InjectorService,
    @Configuration() private settings: Configuration,
    private routeService: RouteService
  ) {
    super(injectorService as any, {filter: {type: ProviderType.CONTROLLER}});
  }

  /**
   * @deprecated
   */
github TypedProject / ts-express-decorators / packages / common / src / converters / services / ConverterService.ts View on Github external
import {getClass, isArrayOrArrayClass, isEmpty, isPrimitiveOrPrimitiveClass, Metadata, Store, Type} from "@tsed/core";
import {Configuration, Injectable, InjectorService} from "@tsed/di";
import {BadRequest} from "ts-httpexceptions";
import {PropertyMetadata} from "../../jsonschema/class/PropertyMetadata";
import {PropertyRegistry} from "../../jsonschema/registries/PropertyRegistry";
import {CONVERTER} from "../constants/index";
import {ConverterDeserializationError} from "../errors/ConverterDeserializationError";
import {ConverterSerializationError} from "../errors/ConverterSerializationError";
import {RequiredPropertyError} from "../errors/RequiredPropertyError";
import {UnknownPropertyError} from "../errors/UnknownPropertyError";
import {IConverter, IConverterOptions, IDeserializer, ISerializer} from "../interfaces/index";

@Injectable()
export class ConverterService {
  private validationModelStrict = true;

  constructor(private injectorService: InjectorService, @Configuration() configuration: Configuration) {
    this.validationModelStrict = configuration.get("validationModelStrict");
  }

  /**
   * Return a JsonMetadata for a properties.
   * @param properties
   * @param propertyKey
   * @returns {undefined|V|string|any|T|IDBRequest}
   */
  static getPropertyMetadata(
    properties: Map,
    propertyKey: string | symbol