REFACTOR: Add Auth Validators

This commit is contained in:
Victor Radael
2022-03-28 13:06:03 -03:00
parent 25d99089db
commit 7a95ec537f
24 changed files with 656 additions and 10355 deletions
@@ -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);
}
}
}