dvbooking/src/app.module.ts
2025-10-27 14:15:19 +01:00

36 lines
986 B
TypeScript

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule, ConfigService } from '@nestjs/config';
const moduleTypeOrm = TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
return {
type: 'postgres',
host: configService.get<string>('DATABASE_HOST'),
port: parseInt(configService.get<string>('DATABASE_PORT') as string,10),
username: configService.get<string>('DATABASE_USER'),
password: configService.get<string>('DATABASE_PASS'),
database: configService.get<string>('DATABASE_NAME'),
entities: [],
// synchronize: true,
};
},
});
@Module({
imports: [
ConfigModule.forRoot(),
moduleTypeOrm
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {
}