From 059af0d76d86ab37b8e091c437eba28d19566d29 Mon Sep 17 00:00:00 2001 From: TheManus88 Date: Tue, 17 Sep 2024 17:47:33 -0600 Subject: [PATCH] get carreras --- src/app.module.ts | 2 ++ src/carrera/carreras.controller.ts | 22 ++++++++++++++++++++++ src/carrera/carreras.module.ts | 12 ++++++++++++ src/carrera/carreras.service.ts | 17 +++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 src/carrera/carreras.controller.ts create mode 100644 src/carrera/carreras.module.ts create mode 100644 src/carrera/carreras.service.ts diff --git a/src/app.module.ts b/src/app.module.ts index 8e800fd..f72e8da 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -21,6 +21,7 @@ import { EjesEstrategicosModule } from './ejesEstrategicos/ejesEstrategicos.modu import { LineasProgramaticasController } from './lineasProgramaticas/lineasProgramaticas.controller'; import { LineasProgramaticasService } from './lineasProgramaticas/lineasProgramaticas.service'; import { LineasProgramaticasModule } from './lineasProgramaticas/lineasProgramaticas.module'; +import { CarreraModule } from './carrera/carreras.module'; config({ path: '.env' }); @Module({ imports: [ @@ -28,6 +29,7 @@ config({ path: '.env' }); UsersModule, EjesEstrategicosModule, LineasProgramaticasModule, + CarreraModule, ConfigModule.forRoot({ isGlobal: true, }), diff --git a/src/carrera/carreras.controller.ts b/src/carrera/carreras.controller.ts new file mode 100644 index 0000000..3744ece --- /dev/null +++ b/src/carrera/carreras.controller.ts @@ -0,0 +1,22 @@ +import { + Controller, + Get, + Header, + HttpCode, + Logger, +} from '@nestjs/common'; + +import { CarrerasService } from './carreras.service'; + +@Controller('carrera') +export class CarrerasController { + constructor(private readonly carrerasService: CarrerasService) {} + + @Header('content-type', 'application/json') + @Get('carreras') + @HttpCode(200) + getEjesEstrategicos() { + Logger.log('Carreras', 'getCarreras'); + return this.carrerasService.findCarreras(); + } +} diff --git a/src/carrera/carreras.module.ts b/src/carrera/carreras.module.ts new file mode 100644 index 0000000..ef5fd36 --- /dev/null +++ b/src/carrera/carreras.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Carrera } from '../entities/carreras.entity'; +import { CarrerasService } from './carreras.service'; +import { CarrerasController } from './carreras.controller'; +@Module({ + imports: [TypeOrmModule.forFeature([Carrera])], + providers: [CarrerasService], + controllers: [CarrerasController], + exports: [TypeOrmModule.forFeature([CarrerasService])], +}) +export class CarreraModule {} diff --git a/src/carrera/carreras.service.ts b/src/carrera/carreras.service.ts new file mode 100644 index 0000000..4bc92dc --- /dev/null +++ b/src/carrera/carreras.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { EjeEstrategico } from '../entities/ejesEstrategicos.entity'; +import { Repository } from 'typeorm'; +import { Carrera } from '../entities/carreras.entity'; + +@Injectable() +export class CarrerasService { + constructor( + @InjectRepository(Carrera) + private carreraRepository: Repository, + ) {} + + findCarreras(): Promise { + return this.carreraRepository.find({}); + } +}