generated from fahricansecer/boilerplate-be
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { Module, Logger as NestLogger } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
|
||||
import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler';
|
||||
@@ -41,6 +41,7 @@ import { AdminModule } from './modules/admin/admin.module';
|
||||
import { HealthModule } from './modules/health/health.module';
|
||||
import { GeminiModule } from './modules/gemini/gemini.module';
|
||||
import { CmsModule } from './modules/cms/cms.module';
|
||||
import { MailModule } from './modules/mail/mail.module';
|
||||
|
||||
// Guards
|
||||
import {
|
||||
@@ -71,7 +72,7 @@ import {
|
||||
LoggerModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
useFactory: (configService: ConfigService) => {
|
||||
return {
|
||||
pinoHttp: {
|
||||
level: configService.get('app.isDevelopment') ? 'debug' : 'info',
|
||||
@@ -121,6 +122,7 @@ import {
|
||||
isGlobal: true,
|
||||
imports: [ConfigModule],
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
const logger = new NestLogger('CacheModule');
|
||||
const useRedis = configService.get('REDIS_ENABLED', 'false') === 'true';
|
||||
|
||||
if (useRedis) {
|
||||
@@ -132,18 +134,18 @@ import {
|
||||
},
|
||||
ttl: 60 * 1000, // 1 minute default
|
||||
});
|
||||
console.log('✅ Redis cache connected');
|
||||
logger.log('✅ Redis cache connected');
|
||||
return {
|
||||
store: store as unknown as any,
|
||||
ttl: 60 * 1000,
|
||||
};
|
||||
} catch {
|
||||
console.warn('⚠️ Redis connection failed, using in-memory cache');
|
||||
logger.warn('⚠️ Redis connection failed, using in-memory cache');
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to in-memory cache
|
||||
console.log('📦 Using in-memory cache');
|
||||
logger.log('📦 Using in-memory cache');
|
||||
return {
|
||||
ttl: 60 * 1000,
|
||||
};
|
||||
@@ -166,6 +168,9 @@ import {
|
||||
// CMS Module
|
||||
CmsModule,
|
||||
|
||||
// Mail Module
|
||||
MailModule,
|
||||
|
||||
// Serve uploaded files
|
||||
ServeStaticModule.forRoot({
|
||||
rootPath: path.join(__dirname, '..', 'uploads'),
|
||||
@@ -210,4 +215,10 @@ import {
|
||||
},
|
||||
],
|
||||
})
|
||||
export class AppModule { }
|
||||
export class AppModule {
|
||||
private readonly logger = new NestLogger(AppModule.name);
|
||||
|
||||
constructor() {
|
||||
this.logger.log('AppModule initialized');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user