mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 02:39:07 +00:00
REFACTOR: Project Pattern and AuthClient (DUC)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
import { DucProtofile } from '@victorradael/protospack';
|
||||
|
||||
export class AuthClient {
|
||||
config(): ClientOptions {
|
||||
return {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.DUC_URL,
|
||||
package: 'duc',
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: DucProtofile,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
arrays: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
|
||||
import { CognitoServiceInterface } from '@victorradael/protospack';
|
||||
|
||||
import { ILogin } from './interfaces';
|
||||
|
||||
export class AuthClientService implements OnModuleInit {
|
||||
private cognitoService: CognitoServiceInterface;
|
||||
constructor(
|
||||
@Inject('AUTH_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
onModuleInit() {
|
||||
this.cognitoService = this.grpcClient.getService<CognitoServiceInterface>(
|
||||
'CognitoProtoService',
|
||||
);
|
||||
}
|
||||
|
||||
async signIn({ username, password }: ILogin): Promise<any> {
|
||||
console.log('CognitoClientService', 'SignIn');
|
||||
|
||||
const tokens = await new Promise((resolve, reject) => {
|
||||
this.cognitoService.signIn({ username, password }).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export interface ILogin {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// import { join } from 'path';
|
||||
// import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
// export const InputsClientConfiguration: ClientOptions = {
|
||||
// transport: Transport.GRPC,
|
||||
// options: {
|
||||
// //url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
|
||||
// url: `127.0.0.1:50052`,
|
||||
// package: 'input',
|
||||
// protoPath: join(__dirname, '..', 'proto', 'input.proto'),
|
||||
// loader: {
|
||||
// enums: String,
|
||||
// objects: true,
|
||||
// arrays: true,
|
||||
// },
|
||||
// },
|
||||
// };
|
||||
@@ -0,0 +1,64 @@
|
||||
// import {
|
||||
// Get,
|
||||
// Post,
|
||||
// Controller,
|
||||
// Delete,
|
||||
// OnModuleInit,
|
||||
// Put,
|
||||
// Param,
|
||||
// } from '@nestjs/common';
|
||||
// import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
|
||||
// import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
|
||||
// import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
|
||||
// import { InputGrpcClientService } from './input-grpc-client.service';
|
||||
// import { GrpcClientConfiguration } from './client.config';
|
||||
// import { TestConnectionDTO } from './dto/test-connection-grpc-client.dto';
|
||||
// import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
// @Controller('grpc/input')
|
||||
// export class InputsClientService implements OnModuleInit {
|
||||
// @Client(GrpcClientConfiguration)
|
||||
// private inputServiceClient: ClientGrpc;
|
||||
|
||||
// private inputService: InputGrpcClientService;
|
||||
|
||||
// onModuleInit() {
|
||||
// this.inputService =
|
||||
// this.inputServiceClient.getService<InputGrpcClientService>(
|
||||
// 'InputService',
|
||||
// );
|
||||
// }
|
||||
|
||||
// @Post()
|
||||
// async create(@Payload() createInputDto: CreateInputGrpcClientDto) {
|
||||
// return this.inputService.create(createInputDto);
|
||||
// }
|
||||
|
||||
// @Get()
|
||||
// list() {
|
||||
// return this.inputService.list();
|
||||
// }
|
||||
|
||||
// @Get(':id')
|
||||
// show(@Param() id: string) {
|
||||
// return this.inputService.show(id);
|
||||
// }
|
||||
|
||||
// @Put(':id')
|
||||
// update(
|
||||
// @Payload() updateInputDto: UpdateInputGrpcClientDto,
|
||||
// @Param() id: string,
|
||||
// ) {
|
||||
// return this.inputService.update(id, updateInputDto);
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// remove(@Param() id: string) {
|
||||
// return this.inputService.remove(id);
|
||||
// }
|
||||
|
||||
// @Get('/test-connection')
|
||||
// testConnection(@Payload() testConnectionDTO: TestConnectionDTO) {
|
||||
// return this.inputService.testConnection(testConnectionDTO);
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,17 @@
|
||||
// import { join } from 'path';
|
||||
// import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
// export const OutputsClientConfiguration: ClientOptions = {
|
||||
// transport: Transport.GRPC,
|
||||
// options: {
|
||||
// //url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
|
||||
// url: `127.0.0.1:50053`,
|
||||
// package: 'output',
|
||||
// protoPath: join(__dirname, '..', 'proto', 'output.proto'),
|
||||
// loader: {
|
||||
// enums: String,
|
||||
// objects: true,
|
||||
// arrays: true,
|
||||
// },
|
||||
// },
|
||||
// };
|
||||
@@ -0,0 +1,57 @@
|
||||
// import {
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// OnModuleInit,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// } from '@nestjs/common';
|
||||
// import {
|
||||
// Client,
|
||||
// ClientGrpc,
|
||||
// MessagePattern,
|
||||
// Payload,
|
||||
// } from '@nestjs/microservices';
|
||||
// import { OutputsService } from './outputs.service';
|
||||
// import { CreateOutputDto } from './dto/create-output.dto';
|
||||
// import { UpdateOutputDto } from './dto/update-output.dto';
|
||||
// import { ApiTags } from '@nestjs/swagger';
|
||||
// import { GrpcClientConfiguration } from './client.config';
|
||||
|
||||
// @Controller('output')
|
||||
// export class OutputsClientService implements OnModuleInit {
|
||||
// @Client(GrpcClientConfiguration)
|
||||
// private outputServiceClient: ClientGrpc;
|
||||
|
||||
// private outputService: OutputsService;
|
||||
|
||||
// onModuleInit() {
|
||||
// this.outputService =
|
||||
// this.outputServiceClient.getService<OutputsService>('OutputService');
|
||||
// }
|
||||
// @Post()
|
||||
// create(@Payload() createOutputDto: CreateOutputDto) {
|
||||
// return this.outputService.create(createOutputDto);
|
||||
// }
|
||||
|
||||
// @Get()
|
||||
// list() {
|
||||
// return this.outputService.list();
|
||||
// }
|
||||
|
||||
// @Get(':id')
|
||||
// show(@Param() id: string) {
|
||||
// return this.outputService.show(id);
|
||||
// }
|
||||
|
||||
// @Put(':id')
|
||||
// update(@Param() id: string, @Payload() updateOutputDto: UpdateOutputDto) {
|
||||
// return this.outputService.update(id, updateOutputDto);
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// remove(@Param() id: string) {
|
||||
// return this.outputService.remove(id);
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,17 @@
|
||||
// import { join } from 'path';
|
||||
// import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
// export const PipelinesClientConfiguration: ClientOptions = {
|
||||
// transport: Transport.GRPC,
|
||||
// options: {
|
||||
// //url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
|
||||
// url: `127.0.0.1:50054`,
|
||||
// package: 'pipeline',
|
||||
// protoPath: join(__dirname, '..', 'proto', 'pipeline.proto'),
|
||||
// loader: {
|
||||
// enums: String,
|
||||
// objects: true,
|
||||
// arrays: true,
|
||||
// },
|
||||
// },
|
||||
// };
|
||||
@@ -0,0 +1,68 @@
|
||||
// import {
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// OnModuleInit,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// } from '@nestjs/common';
|
||||
// import {
|
||||
// Client,
|
||||
// ClientGrpc,
|
||||
// MessagePattern,
|
||||
// Payload,
|
||||
// } from '@nestjs/microservices';
|
||||
// import { PipelinesService } from './pipelines.service';
|
||||
// import { CreatePipelineDto } from './dto/create-pipeline.dto';
|
||||
// import { UpdatePipelineDto } from './dto/update-pipeline.dto';
|
||||
// import { GrpcClientConfiguration } from './client.config';
|
||||
|
||||
// @Controller('pipeline')
|
||||
// export class PipelinesClientService implements OnModuleInit {
|
||||
// @Client(GrpcClientConfiguration)
|
||||
// private pipelineServiceClient: ClientGrpc;
|
||||
|
||||
// private pipelineService: PipelinesService;
|
||||
|
||||
// onModuleInit() {
|
||||
// this.pipelineService =
|
||||
// this.pipelineServiceClient.getService<PipelinesService>(
|
||||
// 'PipelineService',
|
||||
// );
|
||||
// }
|
||||
|
||||
// @Post()
|
||||
// create(@Payload() createPipelineDto: CreatePipelineDto) {
|
||||
// return this.pipelineService.create(createPipelineDto);
|
||||
// }
|
||||
|
||||
// @Get()
|
||||
// list() {
|
||||
// return this.pipelineService.list();
|
||||
// }
|
||||
|
||||
// @Get(':id')
|
||||
// show(@Param() id: string) {
|
||||
// return this.pipelineService.show(id);
|
||||
// }
|
||||
|
||||
// @Put(':id')
|
||||
// update(@Param() id: string, @Payload() updatePipelineDto: UpdatePipelineDto) {
|
||||
// return this.pipelineService.update(id, updatePipelineDto);
|
||||
// }
|
||||
|
||||
// @Delete()
|
||||
// remove(@Param() id: string) {
|
||||
// return this.pipelineService.remove(id);
|
||||
// }
|
||||
|
||||
// @Post()
|
||||
// getPipelineLogsMessages(@Param() id: string, @Payload() details: string) {
|
||||
// return this.pipelineService.getPipelineLogsMessages(id, details);
|
||||
// }
|
||||
|
||||
// getPipelineStatus(id: string) {
|
||||
// return this.pipelineService.getPipelineStatus(id);
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,17 @@
|
||||
// import { join } from 'path';
|
||||
// import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
// export const TransformationsClientConfiguration: ClientOptions = {
|
||||
// transport: Transport.GRPC,
|
||||
// options: {
|
||||
// //url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
|
||||
// url: `127.0.0.1:50054`,
|
||||
// package: 'transformation',
|
||||
// protoPath: join(__dirname, '..', 'proto', 'transformation.proto'),
|
||||
// loader: {
|
||||
// enums: String,
|
||||
// objects: true,
|
||||
// arrays: true,
|
||||
// },
|
||||
// },
|
||||
// };
|
||||
@@ -0,0 +1,65 @@
|
||||
// import {
|
||||
// Controller,
|
||||
// Delete,
|
||||
// Get,
|
||||
// OnModuleInit,
|
||||
// Param,
|
||||
// Post,
|
||||
// Put,
|
||||
// } from '@nestjs/common';
|
||||
// import {
|
||||
// Client,
|
||||
// ClientGrpc,
|
||||
// MessagePattern,
|
||||
// Payload,
|
||||
// } from '@nestjs/microservices';
|
||||
// import { TransformationsService } from './transformations.service';
|
||||
// import { CreateTransformationDto } from './dto/create-transformation.dto';
|
||||
// import { UpdateTransformationDto } from './dto/update-transformation.dto';
|
||||
// import { ApiTags } from '@nestjs/swagger';
|
||||
// import { GrpcClientConfiguration } from './client.config';
|
||||
|
||||
// @Controller('transformation')
|
||||
// export class TransformationsClientService implements OnModuleInit {
|
||||
// @Client(GrpcClientConfiguration)
|
||||
// private transformationServiceClient: ClientGrpc;
|
||||
|
||||
// private transformationService: TransformationsService;
|
||||
|
||||
// onModuleInit() {
|
||||
// this.transformationService =
|
||||
// this.transformationServiceClient.getService<TransformationsService>(
|
||||
// 'TransformationService',
|
||||
// );
|
||||
// }
|
||||
|
||||
// @Post()
|
||||
// create(@Payload() createTransformationDto: CreateTransformationDto[]) {
|
||||
// return createTransformationDto.map((transf) =>
|
||||
// this.transformationService.create(transf),
|
||||
// );
|
||||
// }
|
||||
|
||||
// @Get()
|
||||
// list() {
|
||||
// return this.transformationService.list();
|
||||
// }
|
||||
|
||||
// @Get(':id')
|
||||
// show(@Payload() id: string) {
|
||||
// return this.transformationService.show(id);
|
||||
// }
|
||||
|
||||
// @Put(':id')
|
||||
// update(
|
||||
// @Param() id: string,
|
||||
// @Payload() updateTransformationDto: UpdateTransformationDto,
|
||||
// ) {
|
||||
// return this.transformationService.update(id, updateTransformationDto);
|
||||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// remove(@Param() id: string) {
|
||||
// return this.transformationService.remove(id);
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user