diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2024-03-15 20:23:41 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2024-03-15 20:23:41 +0000 |
| commit | aeb8b66375335e8c9d6cb9cb0d8d7da3d8b79628 (patch) | |
| tree | 0ddaa24fc536ac03493d6357e481df31dad77b16 /src/app.module.ts | |
Initial commit
Diffstat (limited to 'src/app.module.ts')
| -rw-r--r-- | src/app.module.ts | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/app.module.ts b/src/app.module.ts new file mode 100644 index 0000000..b79f2c7 --- /dev/null +++ b/src/app.module.ts @@ -0,0 +1,43 @@ +import { Module } from '@nestjs/common'; +import { SessionModule } from './session/session.module'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { FileModule } from './file/file.module'; +import { SeedingService } from './seeder/seeding.service'; +import { ConfigModule, ConfigService } from '@nestjs/config'; +import configuration from './config/configuration'; +import { ScheduleModule } from '@nestjs/schedule'; + +@Module({ + imports: [ + ConfigModule.forRoot({ + load: [configuration], + }), + TypeOrmModule.forRootAsync({ + imports: [ConfigModule], + inject: [ConfigService], + useFactory: (configService: ConfigService) => { + return { + type: 'mysql', + host: configService.get<string>('database.host'), + port: configService.get<number>('database.port'), + username: configService.get<string>('database.username'), + password: configService.get<string>('database.password'), + database: configService.get<string>('database.database'), + autoLoadEntities: true, + synchronize: true, + }; + }, + }), + ScheduleModule.forRoot(), + SessionModule, + FileModule, + ], + providers: [SeedingService], +}) +export class AppModule { + constructor(private readonly seedingService: SeedingService) {} + + async onApplicationBootstrap(): Promise<void> { + await this.seedingService.seed(); + } +} |
