Files
api-AT/src/app.module.ts
T

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-09-04 20:17:04 -04:00
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
2025-09-04 20:17:04 -04:00
import { AppController } from './app.controller';
import { AppService } from './app.service';
2025-09-04 21:04:15 -04:00
import { TypeOrmModule } from '@nestjs/typeorm';
import { StudentModule } from './student/student.module';
import { UserModule } from './user/user.module';
2025-09-04 21:04:15 -04:00
import { User } from './user/entities/user.entity';
2025-09-04 20:17:04 -04:00
@Module({
2025-09-04 21:04:15 -04:00
imports: [
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
}),
TypeOrmModule.forRootAsync({
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
type: 'mariadb',
host: configService.get<string>('DB_HOST'),
port: configService.get<number>('DB_PORT'),
username: configService.get<string>('DB_USER'),
password: configService.get<string>('DB_PASSWORD'),
database: configService.get<string>('DB_NAME'),
entities: [User],
synchronize: false,
}),
2025-09-04 21:04:15 -04:00
}),
UserModule,
],
2025-09-04 20:17:04 -04:00
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}