Conexiondb
This commit is contained in:
Generated
+526
-74
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -21,10 +21,14 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^10.0.0",
|
||||
"@nestjs/config": "^3.2.2",
|
||||
"@nestjs/core": "^10.0.0",
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"@nestjs/typeorm": "^10.0.2",
|
||||
"mysql2": "^3.10.0",
|
||||
"reflect-metadata": "^0.2.0",
|
||||
"rxjs": "^7.8.1"
|
||||
"rxjs": "^7.8.1",
|
||||
"typeorm": "^0.3.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.0.0",
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Controller } from '@nestjs/common';
|
||||
|
||||
@Controller()
|
||||
export class ProfesorController {}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
https://docs.nestjs.com/modules
|
||||
*/
|
||||
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
})
|
||||
export class ProfesorModule { }
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
https://docs.nestjs.com/providers#services
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class ProfesorService {}
|
||||
@@ -1,12 +1,16 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
constructor(private readonly appService: AppService,
|
||||
private configservice: ConfigService
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
console.log("Todo bien", this.configservice.get("DATABASE_NAME"))
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
||||
|
||||
+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 { }
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
console.log("Todo bien")
|
||||
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user