import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { FuelModule } from './fuel/fuel.module';
import { GeneralModule } from './general/general.module';
import { EmsModule } from './ems/ems.module';
import { TilesModule } from './tiles/tiles.module';
import { GisModule } from './gis/gis.module';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot({
      type: 'sqlite',
      database: 'ems.db',
      synchronize: true,
      name: 'sqliteConnection'
    }),
    TypeOrmModule.forRoot({
      type: 'mssql',
      host: process.env.FUEL_DB_HOST,
      port: 1433,
      username: process.env.FUEL_DB_USER,
      password: process.env.FUEL_DB_PASSWORD,
      database: 'isFuels',
      options: {
        encrypt: false,
        trustServerCertificate: true
      },
      synchronize: false,
      autoLoadEntities: true,
      name: 'fuelConnection'
    }),
    TypeOrmModule.forRoot({
      type: 'mssql',
      host: process.env.EMS_DB_HOST,
      port: Number(process.env.EMS_DB_PORT) || 1433,
      username: process.env.EMS_DB_USER,
      password: process.env.EMS_DB_PASSWORD,
      database: process.env.EMS_DB_NAME,
      options: {
        encrypt: false,
        trustServerCertificate: true
      },
      synchronize: false,
      autoLoadEntities: true,
      name: 'emsConnection'
    }),
    TypeOrmModule.forRoot({
      type: 'mssql',
      host: process.env.GENERAL_DB_HOST,
      port: Number(process.env.GENERAL_DB_PORT) || 1433,
      username: process.env.GENERAL_DB_USER,
      password: process.env.GENERAL_DB_PASSWORD,
      database: process.env.GENERAL_DB_NAME,
      options: {
        encrypt: false,
        trustServerCertificate: true
      },
      synchronize: false,
      autoLoadEntities: true,
      name: 'generalConnection'
    }),
    TypeOrmModule.forRoot({
      type: 'mssql',
      host: process.env.WORLDSTONE_DB_HOST,
      port: Number(process.env.WORLDSTONE_DB_PORT) || 1433,
      username: process.env.WORLDSTONE_DB_USER,
      password: process.env.WORLDSTONE_DB_PASSWORD,
      database: process.env.WORLDSTONE_DB_NAME,
      options: {
        encrypt: false,
        trustServerCertificate: true
      },
      synchronize: false,
      autoLoadEntities: true,
      name: 'worldstoneConnection'
    }),
    // TypeOrmModule.forRoot({
    //   type: 'postgres',
    //   host: process.env.PG_HOST,
    //   port: Number(process.env.PG_PORT) || 5432,
    //   username: process.env.PG_USER,
    //   password: process.env.PG_PASSWORD,
    //   database: process.env.PG_DB,
    //   synchronize: false,
    //   autoLoadEntities: true,
    //   name: 'pgConnection'
    // }),
    FuelModule,
    GeneralModule,
    EmsModule,
    TilesModule,
    GisModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
