Created
January 30, 2020 14:48
-
-
Save vladmelnikov/6fbf6f1b256e3f727fa0ea37c6755cd6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| MiddlewareConsumer, | |
| Module, | |
| NestModule, | |
| OnApplicationBootstrap, | |
| OnApplicationShutdown, | |
| forwardRef, | |
| } from '@nestjs/common'; | |
| import { TypeOrmModule } from '@nestjs/typeorm'; | |
| import { JwtModule } from '@nestjs/jwt'; | |
| import { BullModule } from '@nestjs/bull'; | |
| import { ConfigModule } from '&app/config/config.module'; | |
| import { SrpModule } from '&app/srp/srp.module'; | |
| import { DbOptionsFactory } from './DbOptionsFactory'; | |
| import { EntitySaver } from './EntitySaver'; | |
| import { JwtOptionsFactory } from './JwtOptionsFactory'; | |
| import { Logger } from './Logger'; | |
| import { MinioClient } from './MinioClient'; | |
| import { JwtDecoder } from './JwtDecoder'; | |
| import { IdGenerator } from './IdGenerator'; | |
| import { BullOptionsFactory } from './BullOptionsFactory'; | |
| import { DelayedPushka } from './DelayedPushka/DelayedPushka'; | |
| import { DelayedPushkaConsumer } from './DelayedPushka/DelayedPuskaConsumer'; | |
| import { Configuration } from '&app/config/Configuration'; | |
| @Module({ | |
| imports: [ | |
| ConfigModule, | |
| BullModule.registerQueueAsync({ | |
| name: 'adsasa', | |
| imports: [ConfigModule], | |
| useClass: RedisOptionsFactory, | |
| }), | |
| TypeOrmModule.forRootAsync({ | |
| imports: [ConfigModule], | |
| useClass: DbOptionsFactory, | |
| }), | |
| JwtModule.registerAsync({ | |
| imports: [ConfigModule], | |
| useClass: JwtOptionsFactory, | |
| }), | |
| ], | |
| providers: [], | |
| exports: [], | |
| }) | |
| export class ExternalModule implements NestModule { | |
| constructor() {} | |
| public configure(consumer: MiddlewareConsumer) { | |
| // pass | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@nestjs/common'; | |
| import { BullOptionsFactory as Factory, BullModuleOptions } from '@nestjs/bull'; | |
| import { Configuration } from '&app/config/Configuration'; | |
| @Injectable() | |
| export class BullOptionsFactory implements Factory { | |
| private readonly host: string; | |
| private readonly port: string; | |
| private readonly auth: string; | |
| public constructor(config: Configuration) { | |
| this.host = config.getStringOrThrow('REDIS_HOST'); | |
| this.port = config.getStringOrThrow('REDIS_PORT'); | |
| this.auth = config.getStringOrThrow('REDIS_AUTH'); | |
| console.log('inside constrctor'); | |
| } | |
| public createBullOptions(): BullModuleOptions { | |
| console.log('inside createBullOptions'); // function has not been called | |
| return { | |
| redis: { | |
| host: this.host, | |
| port: Number(this.port), | |
| password: this.auth, | |
| }, | |
| }; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment