import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { RecordModule } from './record/record.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Record } from './record/record.entity';
import { ConfigModule } from '@nestjs/config';

@Module({
  imports: [ConfigModule.forRoot({
    isGlobal: true,
    envFilePath: '.env'
  }),
  TypeOrmModule.forRoot({
    type: 'mysql',
    host: process.env.HOST || 'localhost',
    port: parseInt(process.env.PORT || '3306', 10),
    username: process.env.DB_USERNAME || 'root',
    password: process.env.DB_PASSWORD || 'ADMIN123',
    database: process.env.DATABASE || 'datgroup2026',
    entities: [Record],
    synchronize: true,
    extra: {
    connectionLimit: 50, 
  },
  }),
    RecordModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
