Files
cedetec_api_nest/src/app.module.ts
T

52 lines
2.0 KiB
TypeScript
Raw Normal View History

2023-02-09 16:10:08 -06:00
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule, ConfigService } from '@nestjs/config'
2023-02-09 16:10:08 -06:00
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { EventosModule } from './eventos/eventos.module';
import { ParticipanteController } from './participante/participante.controller';
import { ParticipanteModule } from './participante/participante.module';
import { EventoParticipanteModule } from './evento-participante/evento-participante/evento-participante.module';
import { UsuarioModule } from './usuario/usuario.module';
import { AuthModule } from './auth/auth.module';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { Evento } from './eventos/evento.entity';
import { Participante } from './participante/participante.entity';
import { EventoParticipante } from './evento-participante/evento-participante/eventoParticipante.entity';
import { Usuario } from './usuario/usuario.entity';
2023-02-09 16:10:08 -06:00
@Module({
imports: [
ConfigModule.forRoot({
envFilePath: '.env',
isGlobal: true}),
TypeOrmModule.forRootAsync({
imports:[ConfigModule],
inject:[ConfigService],
useFactory: async (configService: ConfigService) => ({
type: 'mariadb',
host: configService.get('DB_HOST'),
port: configService.get('DB_PORT'),
username: configService.get('DB_USER'),
password: configService.get('DB_PASSWORD'),
database: configService.get('DB_NAME'),
entities: [Evento, Participante, EventoParticipante, Usuario],
synchronize: true
})
}),
EventosModule,
ParticipanteModule,
EventoParticipanteModule,
UsuarioModule,
AuthModule, PassportModule, JwtModule.register({})],
controllers: [AppController, ParticipanteController],
providers: [AppService],
2023-02-09 16:10:08 -06:00
})
export class AppModule {
static port: number
constructor(private readonly configService: ConfigService){
AppModule.port = this.configService.get('PORT')
}
}