Conexiondb
This commit is contained in:
+30
-4
@@ -1,10 +1,36 @@
|
||||
import { ProfesorModule } from './Profesor/profesor.module';
|
||||
import { ProfesorController } from './Profesor/profesor.controller';
|
||||
import { ProfesorService } from './Profesor/profesor.service';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { join } from 'path';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
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_DATABASE"),
|
||||
entities: [],
|
||||
synchronize: configservice.get("DB_SYNCRONIZE")
|
||||
})
|
||||
}),ProfesorModule],
|
||||
controllers: [
|
||||
ProfesorController, AppController],
|
||||
providers: [
|
||||
ProfesorService, AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
export class AppModule { }
|
||||
|
||||
Reference in New Issue
Block a user