mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-25 01:50:04 +00:00
REFACTOR: Add Auth Validators
This commit is contained in:
@@ -6,53 +6,49 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
|
||||
@Controller('pipelines')
|
||||
export class PipelinesController {
|
||||
|
||||
constructor( private pipelinesClientService:PipelinesClientService){}
|
||||
constructor(private pipelinesClientService: PipelinesClientService) {}
|
||||
|
||||
@Get(':id/status')
|
||||
async getPipelineStatus(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE STATUS ROUTE');
|
||||
async getPipelineStatus(@Param() params) {
|
||||
const { id } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/pipeline/${id}`,
|
||||
'ON GET PIPELINE STATUS ROUTE',
|
||||
);
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineStatus(id)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.getPipelineStatus(id);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Get(':id/:details')
|
||||
async getPipelineLogs(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE LOGS ROUTE');
|
||||
async getPipelineLogs(@Param() params) {
|
||||
const { id, details } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/pipeline/${id}`,
|
||||
'ON GET PIPELINE LOGS ROUTE',
|
||||
);
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineLogsMessages(id,details)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.getPipelineLogsMessages(id, details);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createPipelineDto) {
|
||||
console.log(process.env.DEV_URL + `/pipelines`, 'ON CREATE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.create(createPipelineDto)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.create(createPipelineDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -61,49 +57,42 @@ export class PipelinesController {
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/pipeline`, 'ON Find All ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findAll()
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.findAll();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findOne(id)
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.findOne(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updatePipelineDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
async update(@Payload() updatePipelineDto, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.update(id,updatePipelineDto)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.update(id, updatePipelineDto);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.remove(id)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.remove(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,96 +4,82 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class PipelinesService {
|
||||
constructor(private pipelineClient: PipelinesClientService) {}
|
||||
|
||||
constructor( private pipelineClient: PipelinesClientService){}
|
||||
async create(createPipelineDto) {
|
||||
try {
|
||||
const createPipelineResponse = await this.pipelineClient.create(
|
||||
createPipelineDto,
|
||||
);
|
||||
|
||||
async create(createPipelineDto){
|
||||
try{
|
||||
const createPipelineResponse = await this.pipelineClient.create(createPipelineDto);
|
||||
|
||||
return objectCamelToSnake(createPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(createPipelineResponse);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOnePipelineResponse = await this.pipelineClient.findOne({id});
|
||||
return objectCamelToSnake(findOnePipelineResponse)
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
async findOne(id: string) {
|
||||
try {
|
||||
const findOnePipelineResponse = await this.pipelineClient.findOne({ id });
|
||||
return objectCamelToSnake(findOnePipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
async findAll() {
|
||||
try {
|
||||
const findAllPipelineResponse = await this.pipelineClient.findAll();
|
||||
|
||||
return objectCamelToSnake(findAllPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(findAllPipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
const updatePipelineResponse = await this.pipelineClient.update({
|
||||
id,
|
||||
...data,
|
||||
});
|
||||
|
||||
try{
|
||||
|
||||
const updatePipelineResponse = await this.pipelineClient.update({id,...data});
|
||||
|
||||
return objectCamelToSnake(updatePipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(updatePipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async remove(id: string) {
|
||||
try {
|
||||
const removePipelineResponse = await this.pipelineClient.remove({ id });
|
||||
|
||||
try{
|
||||
|
||||
const removePipelineResponse = await this.pipelineClient.remove({id});
|
||||
|
||||
return removePipelineResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return removePipelineResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineLogsMessages(id: string, details: string) {
|
||||
try {
|
||||
const pipelineLogsResponse =
|
||||
await this.pipelineClient.getPipelineLogsMessages({ id, details });
|
||||
|
||||
async getPipelineLogsMessages(id:string,details:string){
|
||||
|
||||
try{
|
||||
|
||||
const pipelineLogsResponse = await this.pipelineClient.getPipelineLogsMessages({id,details});
|
||||
|
||||
return objectCamelToSnake(pipelineLogsResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(pipelineLogsResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineStatus(id:string){
|
||||
async getPipelineStatus(id: string) {
|
||||
try {
|
||||
const pipelineStatusResponse =
|
||||
await this.pipelineClient.getPipelineStatus({ id });
|
||||
|
||||
try{
|
||||
|
||||
const pipelineStatusResponse = await this.pipelineClient.getPipelineStatus({id});
|
||||
|
||||
return objectCamelToSnake(pipelineStatusResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(pipelineStatusResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user