Local Connections

This commit is contained in:
Victor Radael
2022-09-02 12:19:44 -03:00
parent 6d21f29005
commit 24d8f832fa
6 changed files with 51 additions and 17 deletions
@@ -7,6 +7,7 @@ import {
Param,
Post,
Put,
Headers,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AuthenticateCondition } from 'src/authentication/authentication.decorator';
@@ -14,6 +15,8 @@ import { PERMISSIONS } from '../../authentication/permissions.enum';
import { PipelinesService } from './pipelines.service';
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { Messages } from '@dadosfera/protospack-v2/dist/lib/PipelineV2';
import { RequestUser, User } from 'src/authentication/user.decorator';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
@ApiTags('Pipelines')
@Controller('pipelinesV2')
@@ -48,24 +51,50 @@ export class PipelinesController {
}
@Post()
async create(@Body() createPipelineDto: Messages.PipelineV2CreateRequest) {
async create(
@Headers('Dadosfera-Lang') language,
@User() user: RequestUser,
@Body() createPipelineDto: Messages.PipelineV2CreateRequest,
) {
this.logger.info(process.env.DEV_URL + `/pipelines ON CREATE ROUTE`);
const { customer_id, customer_name, username, user_id } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
username,
user_id,
language,
});
const response = await this.pipelinesClientService.create(
createPipelineDto,
metadata,
);
return response;
}
@Get()
async findAll(@Body() data) {
async findAll(
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language,
@Body() data,
) {
this.logger.info(process.env.DEV_URL + `/pipeline ON Find All ROUTE`, {
user: data.info.user_id,
customer: data.info.customer,
});
const response = await this.pipelinesClientService.findAll(data);
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
language,
});
const response = await this.pipelinesClientService.findAll(data, metadata);
return response;
}