mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-30 12:10:04 +00:00
REFACTOR: Add Auth Validators
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import {
|
||||
OnModuleInit,
|
||||
Inject,
|
||||
} from '@nestjs/common';
|
||||
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { InputService } from '@victorradael/protospack';
|
||||
import { ICreateInputRequest, IIdRequest, ITestConnectionRequest, UpdateInputRequest } from './interfaces';
|
||||
import { IIdRequest, ITestConnectionRequest } from './interfaces';
|
||||
|
||||
export class InputsClientService implements OnModuleInit {
|
||||
private inputService: InputService;
|
||||
@@ -12,15 +9,12 @@ export class InputsClientService implements OnModuleInit {
|
||||
@Inject('INPUTS_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
|
||||
onModuleInit() {
|
||||
this.inputService =
|
||||
this.grpcClient.getService<InputService>(
|
||||
'InputService',
|
||||
);
|
||||
this.grpcClient.getService<InputService>('InputService');
|
||||
}
|
||||
|
||||
async create(createInputDto: ICreateInputRequest ) {
|
||||
async create(createInputDto) {
|
||||
console.log('InputClientService', 'Create');
|
||||
|
||||
const createInputResponse = await new Promise((resolve, reject) => {
|
||||
@@ -43,17 +37,15 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return createInputResponse;
|
||||
|
||||
}
|
||||
|
||||
|
||||
async findOne(data: IIdRequest ) {
|
||||
async findOne(data: IIdRequest) {
|
||||
console.log('InputClientService', 'FindOne');
|
||||
|
||||
const { id } = data
|
||||
const { id } = data;
|
||||
|
||||
const findOneInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.FindOne({id}).subscribe({
|
||||
this.inputService.FindOne({ id }).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -72,11 +64,9 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return findOneInputResponse;
|
||||
|
||||
}
|
||||
|
||||
|
||||
async findAll(data) {
|
||||
async findAll({}) {
|
||||
console.log('InputClientService', 'FindAll');
|
||||
|
||||
const findAllInputResponse = await new Promise((resolve, reject) => {
|
||||
@@ -99,11 +89,9 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return findAllInputResponse;
|
||||
|
||||
}
|
||||
|
||||
|
||||
async update(updateInputDTO:UpdateInputRequest) {
|
||||
async update(updateInputDTO) {
|
||||
console.log('InputClientService', 'Update');
|
||||
const updateInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.Update(updateInputDTO).subscribe({
|
||||
@@ -125,10 +113,9 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return updateInputResponse;
|
||||
|
||||
}
|
||||
|
||||
async remove(idRequest:IIdRequest) {
|
||||
async remove(idRequest: IIdRequest) {
|
||||
console.log('InputClientService', 'Remove');
|
||||
|
||||
const removeInputResponse = await new Promise((resolve, reject) => {
|
||||
@@ -151,10 +138,9 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return removeInputResponse;
|
||||
|
||||
}
|
||||
|
||||
async testConnection(data:ITestConnectionRequest) {
|
||||
async testConnection(data: ITestConnectionRequest) {
|
||||
console.log('InputClientService', 'TestCOnnection');
|
||||
|
||||
const testConnectionResponse = await new Promise((resolve, reject) => {
|
||||
@@ -177,7 +163,5 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return testConnectionResponse;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+4
-6
@@ -8,7 +8,7 @@ interface Values {
|
||||
engine: string;
|
||||
schema: string;
|
||||
}
|
||||
|
||||
|
||||
interface Cron {
|
||||
hours: string[];
|
||||
hour_interval: boolean;
|
||||
@@ -29,16 +29,14 @@ interface Cron {
|
||||
}
|
||||
|
||||
export interface ICreateInputRequest {
|
||||
|
||||
cron: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
operation: string;
|
||||
|
||||
}
|
||||
export interface IIdRequest{
|
||||
id:string;
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface UpdateInputRequest {
|
||||
@@ -53,4 +51,4 @@ interface UpdateInputRequest {
|
||||
export interface ITestConnectionRequest {
|
||||
plugin: string;
|
||||
values: Values;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user