mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-04 11:29:07 +00:00
maestro connection with microservices - clients and modules
This commit is contained in:
@@ -1,83 +1,98 @@
|
||||
// import {
|
||||
// Body,
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// Redirect,
|
||||
// } from '@nestjs/common';
|
||||
// import { Payload } from '@nestjs/microservices';
|
||||
// import axios from 'axios';
|
||||
// import { Console } from 'console';
|
||||
// // import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
||||
// // import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import axios from 'axios';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
|
||||
// @Controller('input')
|
||||
// export class InputsController {
|
||||
// @Get('/test-connection')
|
||||
// async testConnection() {
|
||||
// console.log(
|
||||
// process.env.DEV_URL + `/test-connection`,
|
||||
// 'ON TEST CONNECTION ROUTE',
|
||||
// );
|
||||
// await axios
|
||||
// .get(process.env.DEV_URL + `/test-connection`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Controller('input')
|
||||
export class InputsController {
|
||||
|
||||
// @Post()
|
||||
// async create(@Body() createInputDto: CreateInputGrpcClientDto) {
|
||||
// console.log(createInputDto);
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
constructor( private inputsClientService:InputsClientService){}
|
||||
|
||||
// await axios
|
||||
// .post(process.env.DEV_URL + '/input', createInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Get('/test-connection')
|
||||
async testConnection(@Body() data) {
|
||||
console.log(
|
||||
process.env.DEV_URL + `/test-connection`,
|
||||
'ON TEST CONNECTION ROUTE',
|
||||
);
|
||||
|
||||
console.log(data)
|
||||
|
||||
// @Get()
|
||||
// async list() {
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON GET ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const response = await inputService.testConnection(data)
|
||||
|
||||
// @Get('/:id')
|
||||
// async show(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON SHOW ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input/${id}`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
return response;
|
||||
}
|
||||
|
||||
// @Put(':id')
|
||||
// async update(
|
||||
// @Payload() updateInputDto: UpdateInputGrpcClientDto,
|
||||
// @Param() id: string,
|
||||
// ) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
// await axios
|
||||
// .put(process.env.DEV_URL + `input/${id}`, updateInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Post()
|
||||
async create(@Body() createInputDto) {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const response = await inputService.create(createInputDto)
|
||||
|
||||
// await axios
|
||||
// .delete(process.env.DEV_URL + `/input/${id}`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON FIND ALL ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
|
||||
const response = await inputService.findAll()
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const { id } = params
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON FIND ONE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
|
||||
const response = await inputService.findOne(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateInputDto,
|
||||
@Param() params,
|
||||
) {
|
||||
|
||||
const {id} = params;
|
||||
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
|
||||
const response = await inputService.update(id,updateInputDto)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
|
||||
const {id} = params
|
||||
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
|
||||
const response = await inputService.remove(id)
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,87 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
|
||||
@Injectable()
|
||||
export class InputsService {
|
||||
check() {
|
||||
return { message: 'Ok' };
|
||||
|
||||
constructor( private inputClient: InputsClientService){}
|
||||
|
||||
|
||||
async create(data){
|
||||
|
||||
try{
|
||||
|
||||
const createInputResponse = await this.inputClient.create(data)
|
||||
|
||||
return createInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
|
||||
const findAllInputResponse = await this.inputClient.findAll({})
|
||||
|
||||
return findAllInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const findOneInputResponse = await this.inputClient.findOne({id})
|
||||
return findOneInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string,data){
|
||||
|
||||
try{
|
||||
|
||||
const updateInputResponse = await this.inputClient.update({id,...data})
|
||||
|
||||
return updateInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
|
||||
try{
|
||||
const removeInputResponse = await this.inputClient.remove({id})
|
||||
|
||||
return removeInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async testConnection(data){
|
||||
|
||||
try{
|
||||
|
||||
const testConnectionInputResponse = await this.inputClient.testConnection(data)
|
||||
|
||||
return testConnectionInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +1,77 @@
|
||||
// import {
|
||||
// Body,
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// Redirect,
|
||||
// } from '@nestjs/common';
|
||||
// import { Payload } from '@nestjs/microservices';
|
||||
// import axios from 'axios';
|
||||
// import { Console } from 'console';
|
||||
// // import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
||||
// // import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
import { OutputsService } from './outputs.service';
|
||||
|
||||
// @Controller('outputs')
|
||||
// export class OutputsController {
|
||||
// @Get('/test-connection')
|
||||
// async testConnection() {
|
||||
// console.log(
|
||||
// process.env.DEV_URL + `/test-connection`,
|
||||
// 'ON TEST CONNECTION ROUTE',
|
||||
// );
|
||||
// await axios
|
||||
// .get(process.env.DEV_URL + `/test-connection`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Controller('outputs')
|
||||
export class OutputsController {
|
||||
|
||||
// @Post()
|
||||
// async create(@Body() createInputDto: CreateInputGrpcClientDto) {
|
||||
// console.log(createInputDto);
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
constructor( private outputsClientService:OutputsClientService){}
|
||||
|
||||
// await axios
|
||||
// .post(process.env.DEV_URL + '/input', createInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Post()
|
||||
async create(@Body() createOutputDto) {
|
||||
console.log(process.env.DEV_URL + `/output`, 'ON CREATE ROUTE');
|
||||
|
||||
// @Get()
|
||||
// async list() {
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON GET ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.create(createOutputDto)
|
||||
|
||||
// @Get('/:id')
|
||||
// async show(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON SHOW ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input/${id}`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
return response;
|
||||
}
|
||||
|
||||
// @Put(':id')
|
||||
// async update(
|
||||
// @Payload() updateInputDto: UpdateInputGrpcClientDto,
|
||||
// @Param() id: string,
|
||||
// ) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
// await axios
|
||||
// .put(process.env.DEV_URL + `input/${id}`, updateInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Get()
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/output`, 'ON Find All ROUTE');
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.findAll()
|
||||
|
||||
// await axios
|
||||
// .delete(process.env.DEV_URL + `/input/${id}`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.findOne(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateOutputDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.update(id,updateOutputDto)
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.remove(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,69 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
|
||||
@Injectable()
|
||||
export class OutputsService {
|
||||
check() {
|
||||
return { message: 'Ok' };
|
||||
|
||||
constructor( private outputClient: OutputsClientService){}
|
||||
|
||||
async create(createOutputDto){
|
||||
try{
|
||||
const createOutputResponse = await this.outputClient.create(createOutputDto);
|
||||
|
||||
return createOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOneOutputResponse = await this.outputClient.findOne({id});
|
||||
return findOneOutputResponse
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllOutputResponse = await this.outputClient.findAll();
|
||||
|
||||
return findAllOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
|
||||
const updateOutputResponse = await this.outputClient.update({id,...data});
|
||||
|
||||
return updateOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const removeOutputResponse = await this.outputClient.remove({id});
|
||||
|
||||
return removeOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +1,109 @@
|
||||
// import {
|
||||
// Body,
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// Redirect,
|
||||
// } from '@nestjs/common';
|
||||
// import { Payload } from '@nestjs/microservices';
|
||||
// import axios from 'axios';
|
||||
// import { Console } from 'console';
|
||||
// // import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
||||
// // import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
|
||||
// @Controller('pipelines')
|
||||
// export class PipelinesController {
|
||||
// @Get('/test-connection')
|
||||
// async testConnection() {
|
||||
// console.log(
|
||||
// process.env.DEV_URL + `/test-connection`,
|
||||
// 'ON TEST CONNECTION ROUTE',
|
||||
// );
|
||||
// await axios
|
||||
// .get(process.env.DEV_URL + `/test-connection`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Controller('pipelines')
|
||||
export class PipelinesController {
|
||||
|
||||
// @Post()
|
||||
// async create(@Body() createInputDto: CreateInputGrpcClientDto) {
|
||||
// console.log(createInputDto);
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
constructor( private pipelinesClientService:PipelinesClientService){}
|
||||
|
||||
// await axios
|
||||
// .post(process.env.DEV_URL + '/input', createInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Get(':id/status')
|
||||
async getPipelineStatus(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE STATUS ROUTE');
|
||||
|
||||
// @Get()
|
||||
// async list() {
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON GET ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineStatus(id)
|
||||
|
||||
// @Get('/:id')
|
||||
// async show(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON SHOW ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input/${id}`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
return response;
|
||||
|
||||
// @Put(':id')
|
||||
// async update(
|
||||
// @Payload() updateInputDto: UpdateInputGrpcClientDto,
|
||||
// @Param() id: string,
|
||||
// ) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
// await axios
|
||||
// .put(process.env.DEV_URL + `input/${id}`, updateInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
// await axios
|
||||
// .delete(process.env.DEV_URL + `/input/${id}`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
@Get(':id/:details')
|
||||
async getPipelineLogs(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE LOGS ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineLogsMessages(id,details)
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createPipelineDto) {
|
||||
console.log(process.env.DEV_URL + `/pipelines`, 'ON CREATE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.create(createPipelineDto)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/pipeline`, 'ON Find All ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findAll()
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findOne(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updatePipelineDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.update(id,updatePipelineDto)
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.remove(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,99 @@
|
||||
// import { Injectable } from '@nestjs/common';
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
|
||||
// @Injectable()
|
||||
// export class PipelinesService {
|
||||
// check() {
|
||||
// return { message: 'Ok' };
|
||||
// }
|
||||
// }
|
||||
@Injectable()
|
||||
export class PipelinesService {
|
||||
|
||||
constructor( private pipelineClient: PipelinesClientService){}
|
||||
|
||||
async create(createPipelineDto){
|
||||
try{
|
||||
const createPipelineResponse = await this.pipelineClient.create(createPipelineDto);
|
||||
|
||||
return objectCamelToSnake(createPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOnePipelineResponse = await this.pipelineClient.findOne({id});
|
||||
return objectCamelToSnake(findOnePipelineResponse)
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllPipelineResponse = await this.pipelineClient.findAll();
|
||||
|
||||
return objectCamelToSnake(findAllPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
|
||||
const updatePipelineResponse = await this.pipelineClient.update({id,...data});
|
||||
|
||||
return objectCamelToSnake(updatePipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const removePipelineResponse = await this.pipelineClient.remove({id});
|
||||
|
||||
return removePipelineResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async getPipelineLogsMessages(id:string,details:string){
|
||||
|
||||
try{
|
||||
|
||||
const pipelineLogsResponse = await this.pipelineClient.getPipelineLogsMessages({id,details});
|
||||
|
||||
return objectCamelToSnake(pipelineLogsResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineStatus(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const pipelineStatusResponse = await this.pipelineClient.getPipelineStatus({id});
|
||||
|
||||
return objectCamelToSnake(pipelineStatusResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,83 +1,79 @@
|
||||
// import {
|
||||
// Body,
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// Redirect,
|
||||
// } from '@nestjs/common';
|
||||
// import { Payload } from '@nestjs/microservices';
|
||||
// import axios from 'axios';
|
||||
// import { Console } from 'console';
|
||||
// // import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
||||
// // import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { TransformationsClientService } from 'src/clients/transformations/client.service';
|
||||
import { TransformationsService } from './transformations.service';
|
||||
|
||||
// @Controller('transformations')
|
||||
// export class TransformationsController {
|
||||
// @Get('/test-connection')
|
||||
// async testConnection() {
|
||||
// console.log(
|
||||
// process.env.DEV_URL + `/test-connection`,
|
||||
// 'ON TEST CONNECTION ROUTE',
|
||||
// );
|
||||
// await axios
|
||||
// .get(process.env.DEV_URL + `/test-connection`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
@Controller('transformations')
|
||||
export class TransformationsController {
|
||||
|
||||
// @Post()
|
||||
// async create(@Body() createInputDto: CreateInputGrpcClientDto) {
|
||||
// console.log(createInputDto);
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
constructor( private transformationsClientService:TransformationsClientService){}
|
||||
|
||||
// await axios
|
||||
// .post(process.env.DEV_URL + '/input', createInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
|
||||
// @Get()
|
||||
// async list() {
|
||||
// console.log(process.env.DEV_URL + `/input`, 'ON GET ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
|
||||
// @Get('/:id')
|
||||
// async show(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON SHOW ROUTE');
|
||||
// await axios.get(process.env.DEV_URL + `/input/${id}`).then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
|
||||
// @Put(':id')
|
||||
// async update(
|
||||
// @Payload() updateInputDto: UpdateInputGrpcClientDto,
|
||||
// @Param() id: string,
|
||||
// ) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
// await axios
|
||||
// .put(process.env.DEV_URL + `input/${id}`, updateInputDto)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param() id: string) {
|
||||
// console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
// await axios
|
||||
// .delete(process.env.DEV_URL + `/input/${id}`)
|
||||
// .then((response) => {
|
||||
// return response;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
@Post()
|
||||
async create(@Body() createTransformationDto) {
|
||||
console.log(process.env.DEV_URL + `/transformation`, 'ON CREATE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.create(createTransformationDto)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/transformation`, 'ON Find All ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.findAll()
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/transformation/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.findOne(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateTransformationDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/transformation/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.update(id,updateTransformationDto)
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/transformation/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.remove(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,77 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { TransformationsClientService } from 'src/clients/transformations/client.service';
|
||||
import { ICreateTransformationsRequest } from 'src/clients/transformations/interfaces';
|
||||
import { trSnakeToCamel } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class TransformationsService {
|
||||
check() {
|
||||
return { message: 'Ok' };
|
||||
|
||||
constructor( private transformationClient: TransformationsClientService){}
|
||||
|
||||
async create(createTransformationDto:ICreateTransformationsRequest){
|
||||
try{
|
||||
|
||||
let convertedDTO = createTransformationDto.transformations.map((tr)=>{
|
||||
|
||||
return trSnakeToCamel(tr)
|
||||
})
|
||||
|
||||
const createTransformationResponse = await this.transformationClient.create({transformations:convertedDTO});
|
||||
|
||||
return createTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOneTransformationResponse = await this.transformationClient.findOne({id});
|
||||
return findOneTransformationResponse
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllTransformationResponse = await this.transformationClient.findAll();
|
||||
|
||||
return findAllTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
|
||||
const updateTransformationResponse = await this.transformationClient.update({id,...data});
|
||||
|
||||
return updateTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const removeTransformationResponse = await this.transformationClient.remove({id});
|
||||
|
||||
return removeTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user