apps/api: use global CacheModule
This commit is contained in:
parent
14327d262e
commit
d2c41fb983
@ -4,10 +4,13 @@ import { AppService } from './app.service';
|
||||
import { env } from './config/env';
|
||||
import { LdapModule } from './ldap/ldap.module';
|
||||
import { LdapTfaModule } from './ldap-tfa/ldap-tfa.module';
|
||||
import { CacheModule } from '@nestjs/cache-manager';
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
import * as redisStore from 'cache-manager-ioredis';
|
||||
import type { RedisOptions } from 'ioredis';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
@ -27,6 +30,13 @@ import { MongooseModule } from '@nestjs/mongoose';
|
||||
AccountModule,
|
||||
LdapTfaModule,
|
||||
MongooseModule.forRoot(`mongodb://${env.MONGO_HOST}`),
|
||||
CacheModule.register<RedisOptions>({
|
||||
host: env.REDIS_HOST,
|
||||
isGlobal: true,
|
||||
port: env.REDIS_PORT,
|
||||
store: redisStore,
|
||||
ttl: env.API_CACHE_TTL,
|
||||
}),
|
||||
],
|
||||
providers: [AppService],
|
||||
})
|
||||
|
||||
@ -1,23 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
||||
import { LdapTfaController } from './ldap-tfa.controller';
|
||||
import { CacheModule } from '@nestjs/cache-manager';
|
||||
import { Module } from '@nestjs/common';
|
||||
import * as redisStore from 'cache-manager-ioredis';
|
||||
import type { RedisOptions } from 'ioredis';
|
||||
import { env } from 'src/config/env';
|
||||
import { LdapModule } from 'src/ldap/ldap.module';
|
||||
import { LdapTfaGateway } from 'src/ldap-tfa/ldap-tfa.gateway';
|
||||
|
||||
@Module({
|
||||
controllers: [LdapTfaController],
|
||||
imports: [
|
||||
LdapModule,
|
||||
CacheModule.register<RedisOptions>({
|
||||
db: 1,
|
||||
host: env.REDIS_HOST,
|
||||
port: env.REDIS_PORT,
|
||||
store: redisStore,
|
||||
ttl: env.API_CACHE_TTL,
|
||||
}),
|
||||
],
|
||||
imports: [LdapModule],
|
||||
providers: [LdapTfaGateway],
|
||||
})
|
||||
export class LdapTfaModule {}
|
||||
|
||||
@ -1,22 +1,11 @@
|
||||
import { LdapController } from './ldap.controller';
|
||||
import { LdapService } from './ldap.service';
|
||||
import { CacheModule } from '@nestjs/cache-manager';
|
||||
import { Module } from '@nestjs/common';
|
||||
import * as redisStore from 'cache-manager-ioredis';
|
||||
import type { RedisOptions } from 'ioredis';
|
||||
import { env } from 'src/config/env';
|
||||
|
||||
@Module({
|
||||
controllers: [LdapController],
|
||||
exports: [LdapService],
|
||||
imports: [
|
||||
CacheModule.register<RedisOptions>({
|
||||
host: env.REDIS_HOST,
|
||||
port: env.REDIS_PORT,
|
||||
store: redisStore,
|
||||
ttl: env.API_CACHE_TTL,
|
||||
}),
|
||||
],
|
||||
imports: [],
|
||||
providers: [LdapService],
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user