Skip to content

Commit

Permalink
chore: adjust environment redis
Browse files Browse the repository at this point in the history
  • Loading branch information
William Koller committed Apr 27, 2022
1 parent 9861d8d commit c27e390
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
20 changes: 8 additions & 12 deletions src/modules/app/app.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AwsModule } from '@/modules/aws/aws.module';
import { BooksModule } from '@/modules/books/books.module';
import { UsersModule } from '@/modules/users/users.module';
import { forwardRef } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { MongooseModule } from '@nestjs/mongoose';
import { CacheModule } from '@/modules/cache/cache.module';
import { ScheduleModule } from '@nestjs/schedule';
Expand All @@ -18,17 +18,13 @@ export const imports = [
envFilePath: envFolderPath.folderPath,
load: [environments],
}),
// MongooseModule.forRootAsync({
// imports: [ConfigModule],
// inject: [ConfigService],
// useFactory: async (config: ConfigService) => ({
// uri: config.get<string>('mongoUri'),
// }),
// }),
MongooseModule.forRoot(
`${process.env.MONGODB_URI}` ||
'mongodb+srv://williamkoller:biczR9yhhr5xjNem@cluster0.yd57j.mongodb.net/db-my-readings?retryWrites=true&w=majority',
),
MongooseModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
uri: config.get<string>('mongoUri'),
}),
}),
ScheduleModule.forRoot(),
forwardRef(() => BooksModule),
forwardRef(() => UsersModule),
Expand Down
18 changes: 3 additions & 15 deletions src/modules/cache/cache.settings.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import { CacheModule as BaseCacheModule } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import * as redisStore from 'cache-manager-redis-store';
import { CachesRepository } from './repositories/caches.repository';

export const imports = [
BaseCacheModule.registerAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
store: redisStore.create({
auth_pass: config.get('redisAuthPass'),
host: config.get('redisHost'),
port: config.get('redisPort'),
no_ready_check: true,
}),
host: config.get('redisHost'),
port: config.get('redisPort'),
ttl: 60 * 3600 * 1000,
}),
BaseCacheModule.register({
store: redisStore,
url: process.env.REDIS_URL,
}),
];

Expand Down

0 comments on commit c27e390

Please sign in to comment.