import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AdminModule } from './admin/admin.module';
import { Admin } from './admin/entities/admin.entity';
import { DbConstants } from './constants/db.constants';
import { AuthAdminModule } from './auth/admin/authAdmin.module';
import { UserModule } from './user/user.module';
import { User } from './user/entities/user.entity';
import { AuthUserModule } from './auth/user/authUser.module';
import { StateModule } from './state/state.module';
import { DatabaseSeederModule } from './database-seeder/database-seeder.module';
import { State } from './state/entities/state.entity';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { Town } from './town/entities/town.entity';
import { TownModule } from './town/town.module';
import { TownTraduction } from './town/entities/town-traduction.entity';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: DbConstants.DB_HOST,
      port: DbConstants.DB_PORT,
      username: DbConstants.DB_USER,
      password: DbConstants.DB_PASSWORD,
      database: DbConstants.DB_NAME,
      entities: [Admin, User, State, Town, TownTraduction],
      synchronize: DbConstants.DB_SYNC,
      logging: true,
    }),
    AuthAdminModule,
    AdminModule,
    UserModule,
    AuthUserModule,
    StateModule,
    DatabaseSeederModule,
    TownModule,
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'static'),
    }),
  ],
  controllers: [AppController],
  providers: [AppService, DatabaseSeederModule],
  exports: [TypeOrmModule],
})
export class AppModule {}
