mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-13 02:29:07 +00:00
REFACTOR: Add Auth Validators
This commit is contained in:
@@ -7,15 +7,13 @@ import {
|
||||
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')
|
||||
@Controller('inputs')
|
||||
export class InputsController {
|
||||
|
||||
constructor( private inputsClientService:InputsClientService){}
|
||||
constructor(private inputsClientService: InputsClientService) {}
|
||||
|
||||
@Get('/test-connection')
|
||||
async testConnection(@Body() data) {
|
||||
@@ -23,11 +21,11 @@ export class InputsController {
|
||||
process.env.DEV_URL + `/test-connection`,
|
||||
'ON TEST CONNECTION ROUTE',
|
||||
);
|
||||
|
||||
console.log(data)
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const response = await inputService.testConnection(data)
|
||||
console.log(data);
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
const response = await inputService.testConnection(data);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -36,8 +34,8 @@ export class InputsController {
|
||||
async create(@Body() createInputDto) {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const response = await inputService.create(createInputDto)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
const response = await inputService.create(createInputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -46,53 +44,46 @@ export class InputsController {
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON FIND ALL ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.findAll()
|
||||
const response = await inputService.findAll();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const { id } = 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)
|
||||
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;
|
||||
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 inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.update(id,updateInputDto)
|
||||
const response = await inputService.update(id, updateInputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const { id } = params;
|
||||
|
||||
const {id} = params
|
||||
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.remove(id)
|
||||
const response = await inputService.remove(id);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,85 +3,69 @@ import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
|
||||
@Injectable()
|
||||
export class InputsService {
|
||||
constructor(private inputClient: InputsClientService) {}
|
||||
|
||||
constructor( private inputClient: InputsClientService){}
|
||||
async create(data) {
|
||||
try {
|
||||
const createInputResponse = await this.inputClient.create(data);
|
||||
|
||||
|
||||
async create(data){
|
||||
|
||||
try{
|
||||
|
||||
const createInputResponse = await this.inputClient.create(data)
|
||||
|
||||
return createInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
async findAll() {
|
||||
try {
|
||||
const findAllInputResponse = await this.inputClient.findAll({});
|
||||
|
||||
try{
|
||||
|
||||
const findAllInputResponse = await this.inputClient.findAll({})
|
||||
|
||||
return findAllInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const findOneInputResponse = await this.inputClient.findOne({id})
|
||||
async findOne(id: string) {
|
||||
try {
|
||||
const findOneInputResponse = await this.inputClient.findOne({ id });
|
||||
return findOneInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string,data){
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
const updateInputResponse = await this.inputClient.update({
|
||||
id,
|
||||
...data,
|
||||
});
|
||||
|
||||
try{
|
||||
|
||||
const updateInputResponse = await this.inputClient.update({id,...data})
|
||||
|
||||
return updateInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async remove(id: string) {
|
||||
try {
|
||||
const removeInputResponse = await this.inputClient.remove({ id });
|
||||
|
||||
try{
|
||||
const removeInputResponse = await this.inputClient.remove({id})
|
||||
|
||||
return removeInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async testConnection(data){
|
||||
async testConnection(data) {
|
||||
try {
|
||||
const testConnectionInputResponse = await this.inputClient.testConnection(
|
||||
data,
|
||||
);
|
||||
|
||||
try{
|
||||
|
||||
const testConnectionInputResponse = await this.inputClient.testConnection(data)
|
||||
|
||||
return testConnectionInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,53 +6,49 @@ import {
|
||||
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 {
|
||||
|
||||
constructor( private pipelinesClientService:PipelinesClientService){}
|
||||
constructor(private pipelinesClientService: PipelinesClientService) {}
|
||||
|
||||
@Get(':id/status')
|
||||
async getPipelineStatus(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE STATUS ROUTE');
|
||||
async getPipelineStatus(@Param() params) {
|
||||
const { id } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/pipeline/${id}`,
|
||||
'ON GET PIPELINE STATUS ROUTE',
|
||||
);
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineStatus(id)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.getPipelineStatus(id);
|
||||
|
||||
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');
|
||||
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)
|
||||
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)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.create(createPipelineDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -61,49 +57,42 @@ export class PipelinesController {
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/pipeline`, 'ON Find All ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findAll()
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.findAll();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = 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)
|
||||
|
||||
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;
|
||||
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)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.update(id, updatePipelineDto);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = 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)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.remove(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,96 +4,82 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class PipelinesService {
|
||||
constructor(private pipelineClient: PipelinesClientService) {}
|
||||
|
||||
constructor( private pipelineClient: PipelinesClientService){}
|
||||
async create(createPipelineDto) {
|
||||
try {
|
||||
const createPipelineResponse = await this.pipelineClient.create(
|
||||
createPipelineDto,
|
||||
);
|
||||
|
||||
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)
|
||||
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 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{
|
||||
async findAll() {
|
||||
try {
|
||||
const findAllPipelineResponse = await this.pipelineClient.findAll();
|
||||
|
||||
return objectCamelToSnake(findAllPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(findAllPipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
const updatePipelineResponse = await this.pipelineClient.update({
|
||||
id,
|
||||
...data,
|
||||
});
|
||||
|
||||
try{
|
||||
|
||||
const updatePipelineResponse = await this.pipelineClient.update({id,...data});
|
||||
|
||||
return objectCamelToSnake(updatePipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(updatePipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async remove(id: string) {
|
||||
try {
|
||||
const removePipelineResponse = await this.pipelineClient.remove({ id });
|
||||
|
||||
try{
|
||||
|
||||
const removePipelineResponse = await this.pipelineClient.remove({id});
|
||||
|
||||
return removePipelineResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
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 });
|
||||
|
||||
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)
|
||||
return objectCamelToSnake(pipelineLogsResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineStatus(id:string){
|
||||
async getPipelineStatus(id: string) {
|
||||
try {
|
||||
const pipelineStatusResponse =
|
||||
await this.pipelineClient.getPipelineStatus({ id });
|
||||
|
||||
try{
|
||||
|
||||
const pipelineStatusResponse = await this.pipelineClient.getPipelineStatus({id});
|
||||
|
||||
return objectCamelToSnake(pipelineStatusResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(pipelineStatusResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { TransformationsClientService } from 'src/clients/transformations/client.service';
|
||||
@@ -14,66 +13,84 @@ import { TransformationsService } from './transformations.service';
|
||||
|
||||
@Controller('transformations')
|
||||
export class TransformationsController {
|
||||
constructor(
|
||||
private transformationsClientService: TransformationsClientService,
|
||||
) {}
|
||||
|
||||
constructor( private transformationsClientService:TransformationsClientService){}
|
||||
@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,
|
||||
);
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,73 +5,66 @@ import { trSnakeToCamel } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class TransformationsService {
|
||||
constructor(private transformationClient: TransformationsClientService) {}
|
||||
|
||||
constructor( private transformationClient: TransformationsClientService){}
|
||||
async create(createTransformationDto: ICreateTransformationsRequest) {
|
||||
try {
|
||||
const convertedDTO = createTransformationDto.transformations.map((tr) => {
|
||||
return trSnakeToCamel(tr);
|
||||
});
|
||||
|
||||
async create(createTransformationDto:ICreateTransformationsRequest){
|
||||
try{
|
||||
const createTransformationResponse =
|
||||
await this.transformationClient.create({
|
||||
transformations: convertedDTO,
|
||||
});
|
||||
|
||||
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)
|
||||
return createTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
data.transformation["id"] = id
|
||||
const updateTransformationResponse = await this.transformationClient.update({...data});
|
||||
|
||||
return updateTransformationResponse
|
||||
|
||||
}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 remove(id:string){
|
||||
async findAll() {
|
||||
try {
|
||||
const findAllTransformationResponse =
|
||||
await this.transformationClient.findAll();
|
||||
|
||||
try{
|
||||
return findAllTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
const removeTransformationResponse = await this.transformationClient.remove({id});
|
||||
|
||||
return removeTransformationResponse
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
data.transformation['id'] = id;
|
||||
const updateTransformationResponse =
|
||||
await this.transformationClient.update({ ...data });
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
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