How to use the @tsed/common.Inject function in @tsed/common

To help you get started, we’ve selected a few @tsed/common 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 / test / units / di / decorators / inject.spec.ts View on Github external
before(() => {
      this.getParamTypesStub = Sinon.stub(Metadata, "getParamTypes").returns([]);
      this.setParamTypesStub = Sinon.stub(Metadata, "setParamTypes");

      Inject(String)(Test.prototype, "propertyKey", 0);
    });
    after(() => {
github TypedProject / ts-express-decorators / test / units / di / decorators / inject.spec.ts View on Github external
before(() => {
      Inject(String)(Test.prototype, "test");
      this.store = Store.from(Test).get("injectableProperties");
    });
github TypedProject / ts-express-decorators / test / integration / app / services / UserService.ts View on Github external
  public constructor(@Inject(User) private userModel: MongooseModel<User>) {}
github TypedProject / ts-express-decorators / examples / mongoose / src / services / calendars / CalendarsService.ts View on Github external
import {Inject, Service} from "@tsed/common";
import {MongooseModel} from "@tsed/mongoose";
import {$log} from "ts-log-debug";
import {Calendar} from "../../models/calendars/Calendar";


@Service()
export class CalendarsService {
  @Inject(Calendar)
  private Calendar: MongooseModel<Calendar>;

  $onInit() {
    this.reload();
  }

  async reload() {
    const calendars = await this.Calendar.find({});

    if (calendars.length === 0) {
      const promises = require("../../../resources/calendars.json").map(calendar => this.save(calendar));
      await Promise.all(promises);
    }
  }

  /**
github TypedProject / ts-express-decorators / src / socketio / decorators / io.ts View on Github external
export function IO(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number) {
  return Inject(SocketIOServer)(target, targetKey, descriptor);
}
github TypedProject / ts-express-decorators / packages / socketio / src / SocketIOModule.ts View on Github external
constructor(
    private injector: InjectorService,
    @Inject(HttpServer) private httpServer: HttpServer,
    @Inject(HttpsServer) private httpsServer: HttpsServer,
    @IO private io: SocketIO.Server,
    private socketIOService: SocketIOService
  ) {}
github TypedProject / ts-express-decorators / src / socketio / services / SocketIOService.ts View on Github external
constructor(
    private injector: InjectorService,
    @Inject(HttpServer) private httpServer: HttpServer,
    @Inject(HttpsServer) private httpsServer: HttpsServer,
    @IO private io: SocketIO.Server,
    private serverSettingsService: ServerSettingsService,
    private converterService: ConverterService
  ) {}
github TypedProject / ts-express-decorators / packages / socketio / src / services / SocketIOService.ts View on Github external
constructor(
    private injector: InjectorService,
    @Inject(HttpServer) private httpServer: HttpServer,
    @Inject(HttpsServer) private httpsServer: HttpsServer,
    @IO private io: SocketIO.Server,
    private serverSettingsService: ServerSettingsService,
    private converterService: ConverterService
  ) {}
github TypedProject / ts-express-decorators / packages / socketio / src / SocketIOModule.ts View on Github external
constructor(
    private injector: InjectorService,
    @Inject(HttpServer) private httpServer: HttpServer,
    @Inject(HttpsServer) private httpsServer: HttpsServer,
    @IO private io: SocketIO.Server,
    private socketIOService: SocketIOService
  ) {}
github TypedProject / ts-express-decorators / src / socketio / services / SocketIOService.ts View on Github external
constructor(
    private injector: InjectorService,
    @Inject(HttpServer) private httpServer: HttpServer,
    @Inject(HttpsServer) private httpsServer: HttpsServer,
    @IO private io: SocketIO.Server,
    private serverSettingsService: ServerSettingsService,
    private converterService: ConverterService
  ) {}