73 lines
2.7 KiB
TypeScript
73 lines
2.7 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { LoggerModule } from 'nestjs-pino';
|
|
import { randomUUID } from 'node:crypto';
|
|
|
|
import { LoggingModule } from './common/logging/logging.module';
|
|
import { Environment, validateEnv } from './config/env.validation';
|
|
import { AuthModule } from './modules/auth/auth.module';
|
|
import { BankCardsModule } from './modules/banking/bank-cards/bank-cards.module';
|
|
import { BrokerageAccountsModule } from './modules/investments/brokerage-accounts/brokerage-accounts.module';
|
|
import { IncomeModule } from './modules/investments/income/income.module';
|
|
import { InstrumentsModule } from './modules/investments/instruments/instruments.module';
|
|
import { OperationsModule } from './modules/investments/operations/operations.module';
|
|
import { PortfolioModule } from './modules/investments/portfolio/portfolio.module';
|
|
import { TbankConnectionModule } from './modules/investments/tbank-connection/tbank-connection.module';
|
|
import { TbankSyncModule } from './modules/investments/tbank-sync/tbank-sync.module';
|
|
import { UpcomingEventsModule } from './modules/investments/upcoming-events/upcoming-events.module';
|
|
import { PrismaModule } from './prisma/prisma.module';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
validate: validateEnv,
|
|
}),
|
|
LoggerModule.forRootAsync({
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService<Environment, true>) => ({
|
|
pinoHttp: {
|
|
level: config.getOrThrow('LOG_LEVEL'),
|
|
messageKey: 'message',
|
|
autoLogging: false,
|
|
genReqId: (request: unknown, response) => {
|
|
const existingId = (request as { id?: unknown }).id;
|
|
const requestId =
|
|
typeof existingId === 'string' ? existingId : randomUUID();
|
|
response.setHeader('X-Request-ID', requestId);
|
|
return requestId;
|
|
},
|
|
redact: [
|
|
'req.headers.authorization',
|
|
'req.headers.cookie',
|
|
'req.body',
|
|
],
|
|
serializers: {
|
|
req: (request: unknown) => {
|
|
const value = request as { id?: unknown; method?: unknown };
|
|
return {
|
|
id: typeof value.id === 'string' ? value.id : undefined,
|
|
method:
|
|
typeof value.method === 'string' ? value.method : undefined,
|
|
};
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
}),
|
|
LoggingModule,
|
|
PrismaModule,
|
|
AuthModule,
|
|
BankCardsModule,
|
|
BrokerageAccountsModule,
|
|
PortfolioModule,
|
|
OperationsModule,
|
|
IncomeModule,
|
|
UpcomingEventsModule,
|
|
InstrumentsModule,
|
|
TbankConnectionModule,
|
|
TbankSyncModule,
|
|
],
|
|
})
|
|
export class AppModule {}
|