import { Module } from '@nestjs/common';
import { LoginServiceController } from './login-service.controller';
import { LoginServiceService } from './login-service.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';
import { RiderCordinates } from './rider-cordinates/rider-cordinates.entity';
import { RiderCordinatesModule } from './rider-cordinates/rider-cordinates.module';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: process.env.LOGIN_DB_HOST,
      port: parseInt(process.env.LOGIN_DB_PORT),
      username: process.env.LOGIN_DB_USERNAME,
      password: process.env.LOGIN_DB_PASSWORD,
      database: process.env.LOGIN_DB_NAME,
      entities: [RiderCordinates, __dirname + '/**/*.entity{.ts,.js}'],
      synchronize: true, // Disable in production
      logging: true,
    }),
    TypeOrmModule.forFeature([RiderCordinates]),
    RiderCordinatesModule,
  ],
  controllers: [LoginServiceController],
  providers: [LoginServiceService],
})
export class LoginServiceModule {}
