@nestjs/common#Inject TypeScript Examples

The following examples show how to use @nestjs/common#Inject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: user.service.ts    From 42_checkIn with GNU General Public License v3.0 7 votes vote down vote up
constructor(
    private readonly authService: AuthService,
    private readonly userRepository: UserRepository,
    private readonly cardRepository: CardRepository,
    @Inject(forwardRef(() => CardService))
    private readonly cardServcie: CardService,
    private readonly logService: LogService,
    private readonly logger: MyLogger,
    private readonly configService: ConfigService,
    private readonly httpService: HttpService,
    private readonly waitingService: WaitingService,
    private readonly waitingRepository: WaitingRepository,
  ) {}
Example #2
Source File: mercurius-gateway.module.ts    From nestjs-mercurius with MIT License 6 votes vote down vote up
constructor(
    protected readonly httpAdapterHost: HttpAdapterHost,
    protected readonly applicationConfig: ApplicationConfig,
    @Inject(GRAPHQL_GATEWAY_MODULE_OPTIONS)
    protected readonly options: MercuriusGatewayModuleOptions,
    protected readonly hookExplorerService: HookExplorerService,
  ) {
    super(httpAdapterHost, applicationConfig, options, hookExplorerService);
  }
Example #3
Source File: ses.service.ts    From nestjs-ses with MIT License 6 votes vote down vote up
constructor(
    @Inject(AKI_KEY) private readonly apiKey,
    @Inject(REGION) private readonly region,
    @Inject(SECRET) private readonly secret,
  ) {
    this.ses = ses.createClient({
      key: apiKey,
      amazon: `https://email.${region}.amazonaws.com`,
      secret,
    });
  }
Example #4
Source File: project.service.ts    From barista with Apache License 2.0 6 votes vote down vote up
constructor(
    @Inject(forwardRef(() => ScanService))
    private readonly scanService: ScanService,
    @Inject(forwardRef(() => BomManualLicenseService))
    private readonly bomManualLicenseService: BomManualLicenseService,
    @Inject(forwardRef(() => ProjectAttributionService))
    private readonly projectAttributionService: ProjectAttributionService,
    @InjectRepository(Project) repo,
  ) {
    super(repo);
  }
Example #5
Source File: read-event-bus.ts    From nestjs-geteventstore with MIT License 6 votes vote down vote up
constructor(
    @Inject(READ_EVENT_BUS_CONFIG)
    private readonly config: ReadEventBusConfigType<EventBase>,
    private readonly prepublish: EventBusPrepublishService<EventBase>,
    commandBus: CommandBus,
    moduleRef: ModuleRef,
  ) {
    super(commandBus, moduleRef);
    this.logger.debug('Registering Read EventBus for EventStore...');
  }
Example #6
Source File: whisp.resolver.ts    From whispr with MIT License 6 votes vote down vote up
constructor(
    private readonly whispService: WhispService,
    private readonly distributionService: DistributionService,
    @Inject('PUB_SUB') private pubSub: PubSubEngine,
  ) {
    this.distributionService.whispSubject.subscribe((whisp) => {
      pubSub.publish('whispAdded', { whispAdded: whisp });
    });
  }
Example #7
Source File: account.controller.ts    From uniauth-backend with MIT License 6 votes vote down vote up
// private readonly logger = new Logger('account');

  constructor(
    private readonly accountService: AccountService,
    @Inject(UserService) private readonly userService: UserService,
    @Inject(AuthService) private readonly authService: AuthService,
    @Inject(ApplicationService) private readonly applicationService: ApplicationService,
    @Inject(MailerService) private readonly mailerService: MailerService,
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger = new Logger('account'),
  ) {}
Example #8
Source File: auth.service.ts    From amplication with Apache License 2.0 6 votes vote down vote up
constructor(
    private readonly jwtService: JwtService,
    private readonly passwordService: PasswordService,
    private readonly prismaService: PrismaService,
    private readonly accountService: AccountService,
    private readonly userService: UserService,
    @Inject(forwardRef(() => WorkspaceService))
    private readonly workspaceService: WorkspaceService
  ) {}
Example #9
Source File: TodoListApplicationService.ts    From remix-hexagonal-architecture with MIT License 6 votes vote down vote up
constructor(
    @Inject(PRISMA) private readonly prisma: Prisma,
    private readonly todoLists: TodoListDatabaseRepository,
    private readonly todoListPermissions: TodoListPermissionsDatabaseRepository,
    private readonly todoListQuery: TodoListDatabaseQuery,
    private readonly collaborators: CollaboratorsAdapter,
    private readonly generateId: GenerateUUID,
    private readonly clock: RealClock,
    private readonly events: NestEvents
  ) {}
Example #10
Source File: http.service.ts    From nestjs-http-promise with MIT License 6 votes vote down vote up
constructor(
        @Inject(AXIOS_INSTANCE_TOKEN)
        private readonly instance: AxiosInstance = Axios,
    ) {
        this.put = this.instance.put;
        this.post = this.instance.post;
        this.patch = this.instance.patch;
        this.head = this.instance.head;
        this.head = this.instance.head;
        this.delete = this.instance.delete;
        this.get = this.instance.get;
        this.request = this.instance.request;
    }
Example #11
Source File: stages.controller.ts    From codeclannigeria-backend with MIT License 6 votes vote down vote up
constructor(
    protected stageService: StagesService,
    @Inject(TracksService)
    private trackService: TracksService,
    @Inject(TasksService)
    private taskService: TasksService
  ) {
    super(stageService);
  }
Example #12
Source File: create-conditional-dep-holder.helper.ts    From nestjs-bullmq with MIT License 6 votes vote down vote up
export function createConditionalDepHolder<T = any>(
  depToken: string,
  optionalDep = BULL_CONFIG_DEFAULT_TOKEN,
  errorFactory = (caller: string) =>
    new MissingBullSharedConfigurationError(depToken, caller),
): Type<IConditionalDepHolder> {
  class ConditionalDepHolder {
    constructor(@Optional() @Inject(depToken) public _dependencyRef: T) {}

    getDependencyRef(caller: string): T {
      if (depToken !== optionalDep && !this._dependencyRef) {
        throw errorFactory(caller);
      }
      return this._dependencyRef;
    }
  }
  return mixin(ConditionalDepHolder);
}
Example #13
Source File: auth.guard.ts    From nest-keycloak-connect with MIT License 6 votes vote down vote up
constructor(
    @Inject(KEYCLOAK_INSTANCE)
    private singleTenant: KeycloakConnect.Keycloak,
    @Inject(KEYCLOAK_CONNECT_OPTIONS)
    private keycloakOpts: KeycloakConnectConfig,
    @Inject(KEYCLOAK_LOGGER)
    private logger: Logger,
    private multiTenant: KeycloakMultiTenantService,
    private readonly reflector: Reflector,
  ) {}
Example #14
Source File: mqtt.explorer.ts    From nest-mqtt with MIT License 6 votes vote down vote up
constructor(
    private readonly discoveryService: DiscoveryService,
    private readonly metadataScanner: MetadataScanner,
    @Inject(MQTT_LOGGER_PROVIDER) private readonly logger: Logger,
    @Inject(MQTT_CLIENT_INSTANCE) private readonly client: Client,
    @Inject(MQTT_OPTION_PROVIDER) private readonly options: MqttModuleOptions,
  ) {
    this.subscribers = [];
  }
Example #15
Source File: tracing.service.ts    From nest-xray with MIT License 6 votes vote down vote up
constructor(
    @Inject(XRAY_CLIENT) private readonly xrayClient: XRayClient,
    private readonly asyncContext: AsyncContext,
    options: TracingConfig
  ) {
    this.config = {
      serviceName: options.serviceName || "example-service",
      rate: options.rate !== undefined ? options.rate : 1,
      daemonAddress: options.daemonAddress || "172.17.0.1:2000",
      plugins: options.plugins || [plugins.EC2Plugin, plugins.ECSPlugin],
    }; // Set defaults
  }
Example #16
Source File: card.service.ts    From 42_checkIn with GNU General Public License v3.0 5 votes vote down vote up
constructor(
    private readonly cardRepository: CardRepository,
    @Inject(forwardRef(() => UserService))
    private readonly userService: UserService,
    private readonly logger: MyLogger,
  ) {}
Example #17
Source File: gcloud-storage.service.ts    From nestjs-gcloud-storage with MIT License 5 votes vote down vote up
constructor(@Inject(GCLOUD_STORAGE_MODULE_OPTIONS) private readonly options: GCloudStorageOptions) {
    this.logger.log(`GCloudStorageService.options ${options}`);

    const bucketName = this.options.defaultBucketname;
    this.bucket = this.storage.bucket(bucketName);
  }
Example #18
Source File: fcm.service.ts    From nestjs-fcm with MIT License 5 votes vote down vote up
constructor(
    @Inject(FCM_OPTIONS) private fcmOptionsProvider: FcmOptions,
    private readonly logger: Logger,
  ) {}
Example #19
Source File: request-scoped.guard.ts    From nestjs-mercurius with MIT License 5 votes vote down vote up
constructor(@Inject('REQUEST_ID') private requestId: number) {
    Guard.COUNTER++;
  }
Example #20
Source File: typegraphql-options-federation.factory.ts    From typegraphql-nestjs with MIT License 5 votes vote down vote up
constructor(
    @Inject(TYPEGRAPHQL_ROOT_FEDERATION_MODULE_OPTIONS)
    private readonly rootModuleOptions: TypeGraphQLRootFederationModuleOptions,
    private readonly optionsPreparatorService: OptionsPreparatorService,
  ) {}
Example #21
Source File: mailgun.service.ts    From nestjs-mailgun with MIT License 5 votes vote down vote up
constructor(
    @Inject(MAILGUN_CONFIGURATION) private readonly configuration: Options,
  ) {
    this.mailgun = new Mailgun(FormData).client(configuration);
  }
Example #22
Source File: write-events-prepublish.service.ts    From nestjs-geteventstore with MIT License 5 votes vote down vote up
constructor(
    private readonly context: Context,
    @Inject(WRITE_EVENT_BUS_CONFIG)
    private readonly config: IWriteEventBusConfig,
  ) {}
Example #23
Source File: create-user.cli.controller.ts    From domain-driven-hexagon with MIT License 5 votes vote down vote up
constructor(
    private readonly commandBus: CommandBus,
    @Inject(createUserCliLoggerSymbol)
    private readonly logger: Logger,
  ) {}
Example #24
Source File: admin.module.ts    From adminjs-nestjs with MIT License 5 votes vote down vote up
constructor(
    private readonly httpAdapterHost: HttpAdapterHost,
    private readonly loader: AbstractLoader,
    @Inject(CONFIG_TOKEN)
    private readonly adminModuleOptions: AdminModuleOptions,
  ) {}
Example #25
Source File: application.controller.ts    From uniauth-backend with MIT License 5 votes vote down vote up
// private readonly logger = new Logger('application');
  constructor(
    private readonly applicationService: ApplicationService,
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger = new Logger('application'),
  ) {}
Example #26
Source File: LocalBlueprintService.ts    From rewind with MIT License 5 votes vote down vote up
constructor(private readonly osuDbDao: OsuDBDao, @Inject(OSU_SONGS_FOLDER) private readonly songsFolder: string) {}
Example #27
Source File: containerBuilder.service.ts    From amplication with Apache License 2.0 5 votes vote down vote up
constructor(@Inject(CONTAINER_BUILDER_OPTIONS) options: ContainerBuilderOptions) {
    super(options);
  }
Example #28
Source File: auth.guard.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
constructor(
    @Inject(KeycloakService)
    private keycloak: KeycloakService,
    @Inject(Reflector.name)
    private readonly reflector: Reflector
  ) {}
Example #29
Source File: AuthenticationEventsConsumer.ts    From remix-hexagonal-architecture with MIT License 5 votes vote down vote up
constructor(
    @Inject(MAILER)
    private readonly mailer: Mailer
  ) {
    assert(process.env.BASE_URL, "no base url configured");
    this.baseUrl = process.env.BASE_URL;
  }