mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-09 06:09:09 +00:00
REFACTOR: inputs inside its own module
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Info } from 'src/clients/inputs/interfaces';
|
||||
import { Method } from 'axios';
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
|
||||
export class InputModel {
|
||||
category: string;
|
||||
@@ -13,15 +12,6 @@ export class InputModel {
|
||||
oauth_code: string;
|
||||
start_date: string;
|
||||
};
|
||||
options?: {
|
||||
oauth?: {
|
||||
get_tokens_url: string;
|
||||
get_tokens_method?: Method;
|
||||
get_tokens_url_params: string;
|
||||
get_tokens_set_response: Record<string, string>;
|
||||
content_type: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class GoogleAnalyticsClientSecrets {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
import {
|
||||
ClientProviderOptions,
|
||||
GrpcOptions,
|
||||
Transport,
|
||||
} from '@nestjs/microservices';
|
||||
import { InputPackages, InputProtoFilePath } from 'protospack';
|
||||
|
||||
export class InputsGrpcClient {
|
||||
private config: GrpcOptions = {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.INFACTORY_URL,
|
||||
package: InputPackages,
|
||||
credentials: process.env.LOCAL_ENV ? undefined : credentials.createSsl(),
|
||||
protoPath: InputProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
arrays: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
providerOptions: ClientProviderOptions = {
|
||||
name: 'InputsGrpcClient',
|
||||
...this.config,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { InputsGrpcClient } from './inputs-client.config';
|
||||
import { InputsController } from './inputs.controller';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
|
||||
const client = new InputsGrpcClient();
|
||||
|
||||
@Module({
|
||||
controllers: [InputsController],
|
||||
providers: [InputsService, InputsClientService, DadosferaLogger],
|
||||
imports: [ClientsModule.register([client.providerOptions])],
|
||||
exports: [InputsService],
|
||||
})
|
||||
export class InputsModule {}
|
||||
@@ -3,7 +3,8 @@ import { Timeout } from '@nestjs/schedule';
|
||||
import { DecodeGrpcStruct } from 'protospack';
|
||||
import CronParser, { CronExpression } from 'cron-parser';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
|
||||
import { IIdRequest } from 'src/clients/inputs/interfaces';
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class InputsService {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '@nestjs/microservices';
|
||||
import { NetworkConfig } from '@dadosfera/protospack-v2';
|
||||
|
||||
export class NetworkConfigClientConfiguration {
|
||||
export class NetworkConfigGrpcClient {
|
||||
private config: GrpcOptions = {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
@@ -15,7 +15,6 @@ export class NetworkConfigClientConfiguration {
|
||||
NetworkConfig.ProtoPackages.ReadPackage,
|
||||
NetworkConfig.ProtoPackages.WritePackage,
|
||||
],
|
||||
// credentials: undefined,
|
||||
credentials:
|
||||
process.env.ENV === 'local' ? undefined : credentials.createSsl(),
|
||||
protoPath: [
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { NetworkConfigClientConfiguration } from './network-config-client.config';
|
||||
import { NetworkConfigController } from './network-config.controller';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
|
||||
describe('NetworkConfigController', () => {
|
||||
let controller: NetworkConfigController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const client = new NetworkConfigClientConfiguration();
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [NetworkConfigController],
|
||||
providers: [NetworkConfigService, DadosferaLogger],
|
||||
imports: [ClientsModule.register([client.providerOptions])],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<NetworkConfigController>(NetworkConfigController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -3,8 +3,8 @@ import { NetworkConfigController } from './network-config.controller';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { NetworkConfigClientConfiguration } from './network-config-client.config';
|
||||
const client = new NetworkConfigClientConfiguration();
|
||||
import { NetworkConfigGrpcClient } from './network-config-client.config';
|
||||
const client = new NetworkConfigGrpcClient();
|
||||
|
||||
@Module({
|
||||
controllers: [NetworkConfigController],
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { NetworkConfigClientConfiguration } from './network-config-client.config';
|
||||
import { NetworkConfigController } from './network-config.controller';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
|
||||
describe('NetworkConfigService', () => {
|
||||
let service: NetworkConfigService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const client = new NetworkConfigClientConfiguration();
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [NetworkConfigController],
|
||||
providers: [NetworkConfigService, DadosferaLogger],
|
||||
imports: [ClientsModule.register([client.providerOptions])],
|
||||
}).compile();
|
||||
|
||||
service = module.get<NetworkConfigService>(NetworkConfigService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -8,10 +8,8 @@ import { Request } from 'express';
|
||||
@ApiTags('oauth')
|
||||
@Controller('oauth')
|
||||
export class OauthController {
|
||||
inputService: InputsService;
|
||||
frontendRedirectUri = '';
|
||||
constructor(private inputsClientService: InputsClientService) {
|
||||
this.inputService = new InputsService(this.inputsClientService);
|
||||
constructor(private inputService: InputsService) {
|
||||
switch (process.env.ENV) {
|
||||
case 'dev':
|
||||
case 'stg':
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { InputsModule } from '../inputs/inputs.module';
|
||||
import { OauthController } from './oauth.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [OauthController],
|
||||
imports: [InputsModule],
|
||||
})
|
||||
export class OauthModule {}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { IIdRequest, Info } from 'src/clients/outputs/interfaces';
|
||||
import { IIdRequest } from 'src/clients/outputs/interfaces';
|
||||
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class OutputsService {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { DecodeGrpcStruct } from 'protospack';
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
|
||||
import { IIdRequest, Info } from 'src/clients/pipelines/interfaces';
|
||||
import { IIdRequest } from 'src/clients/pipelines/interfaces';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
|
||||
Reference in New Issue
Block a user