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
+36 -52
View File
@@ -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);
}
}
}