FEAT: Pipeline Version 2

This commit is contained in:
Victor Radael
2022-09-01 20:46:02 -03:00
parent 2968647e73
commit e526180902
13 changed files with 435 additions and 88 deletions
+50 -18
View File
@@ -18,7 +18,7 @@ import {
RequireAllPermissions,
} from 'src/authentication/authentication.decorator';
import { PERMISSIONS } from 'src/authentication/permissions.enum';
import { User } from 'src/authentication/user.decorator';
import { RequestUser, User } from 'src/authentication/user.decorator';
import { ValidationPipe } from '../../pipes/object-validation.pipe';
import {
ConnectionDetailsRes,
@@ -27,6 +27,7 @@ import {
UpdateConnectionDto,
} from './dtos/connection';
import { CreateConnectionDto } from './dtos/connection';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
@ApiTags('connections')
@ApiBearerAuth()
@@ -45,57 +46,74 @@ export class ConnectionController {
@Post()
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async createConnection(
@User() user,
@User() user: RequestUser,
@Body(new ValidationPipe()) body: CreateConnectionDto,
): Promise<ConnectionRes> {
this.logger.info('/connections - Create Connection');
const { user_id, customer_id, customer_name } = user;
const response: any = await this.clientService.createConnection(body, {
const { user_id, customer_id, customer_name, username } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
username,
});
const response: any = await this.clientService.createConnection(
body,
metadata,
);
return response;
}
@Put('/:id')
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async updateConnection(
@User() user,
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language: string,
@Param('id') id: string,
@Body(new ValidationPipe()) body: UpdateConnectionDto,
): Promise<ConnectionRes> {
this.logger.info('/connections - Update Connection');
const { user_id, customer_id, customer_name } = user;
const response: any = await this.clientService.updateConnection(id, body, {
const { user_id, customer_id, customer_name, username } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
language,
username,
});
const response: any = await this.clientService.updateConnection(
id,
body,
metadata,
);
return response;
}
@Delete('/:id')
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async deleteConnection(
@User() user,
@User() user: RequestUser,
@Param('id') id: string,
): Promise<ConnectionRes> {
this.logger.info('/connections - Delete Connection');
const { user_id, customer_id, customer_name } = user;
const { user_id, customer_id, customer_name, username } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
username,
});
const response: any = await this.clientService.deleteConnection({
body: { id },
info: { user_id, customer_id, customer_name },
metadata,
});
return response;
@@ -104,18 +122,25 @@ export class ConnectionController {
@Get()
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async getAllConnection(
@User() user,
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language,
@Query() queries,
): Promise<ConnectionsRes> {
this.logger.info('/connections - Get All Connection');
const { user_id, customer_id, customer_name } = user;
const { user_id, customer_id, customer_name, username } = user;
const { search, size, page, ...filters } = queries;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
language,
username,
});
const response = await this.clientService.getAllConnection({
body: { search, size, page, filters },
info: { user_id, customer_id, customer_name, language },
metadata,
});
return response;
@@ -124,17 +149,24 @@ export class ConnectionController {
@Get('/:id')
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
async getConnectionDetails(
@User() user,
@User() user: RequestUser,
@Param('id') id,
@Query('details') details,
): Promise<ConnectionDetailsRes> {
this.logger.info('/connections - Get Connection Details');
const { user_id, customer_id, customer_name } = user;
const { user_id, customer_id, customer_name, username } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
username,
details,
});
const response: any = await this.clientService.getConnectionDetails({
body: { id },
info: { user_id, customer_id, customer_name, details },
metadata,
});
if (details === 'true') {