Store exact RUB balances, atomic transfers, linked refunds and versioned edits independently of T-Bank. Add migration, HTTP and durability verification.
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { randomUUID } from 'node:crypto';
|
|
import { LoggerModule } from 'nestjs-pino';
|
|
import { BankCardsModule } from './bank-cards/bank-cards.module';
|
|
import { AuthModule } from './auth/auth.module';
|
|
import { LoggingModule } from './common/logging/logging.module';
|
|
import { Environment, validateEnv } from './config/env.validation';
|
|
import { PrismaModule } from './prisma/prisma.module';
|
|
import { TbankConnectionModule } from './tbank/tbank-connection.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,
|
|
TbankConnectionModule,
|
|
],
|
|
})
|
|
export class AppModule {}
|