mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-06 20:09:07 +00:00
maestro connection with microservices - clients and modules
This commit is contained in:
@@ -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