This commit is contained in:
2025-05-12 11:28:18 +07:00
parent 56df7185f3
commit 6e9bfa4b82
20 changed files with 863 additions and 86 deletions

View File

@@ -3,28 +3,34 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule, ConfigService } from '@nestjs/config';
import * as Joi from 'joi';
@Module({
imports: [
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
type: 'postgres',
host: configService.get<string>('POSTGRES_HOST'),
port: parseInt(configService.get<string>('POSTGRES_PORT', '5432'), 10),
username: configService.get<string>('POSTGRES_USER'),
password: configService.get<string>('POSTGRES_PASSWORD'),
database: configService.get<string>('POSTGRES_DB'),
ssl: {
rejectUnauthorized: false, // Needed for Neon and similar managed DBs
},
synchronize: true, // Disable in production
}),
}),
ConfigModule.forRoot(),
],
controllers: [AppController],
providers: [AppService],
imports: [
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
type: 'postgres',
host: configService.get<string>('POSTGRES_HOST'),
port: parseInt(configService.get<string>('POSTGRES_PORT', '5432'), 10),
username: configService.get<string>('POSTGRES_USER'),
password: configService.get<string>('POSTGRES_PASSWORD'),
database: configService.get<string>('POSTGRES_DB'),
ssl: {
rejectUnauthorized: false, // Needed for Neon and similar managed DBs
},
synchronize: true, // Disable in production
}),
}),
ConfigModule.forRoot({
validationSchema: Joi.object({
JWT_SECRET: Joi.string().required(),
JWT_EXPIRATION_TIME: Joi.string().required(),
})
})
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
export class AppModule {}