mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-06 09:39:08 +00:00
FEAT: Connection Manager
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { Body, Controller, Post, Inject } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { ConnectionClientService } from './client.service';
|
||||
import { CreateConnectionDto } from './dtos/create-connection';
|
||||
import { DadosferaLogger } from 'dadosfera-logs';
|
||||
import {
|
||||
Authenticated,
|
||||
RequireAllPermissions,
|
||||
} from 'src/authentication/authentication.decorator';
|
||||
import { Permissions } from 'src/authentication/permissions.enum';
|
||||
import { User } from 'src/authentication/user.decorator';
|
||||
import { ValidationPipe } from '../../pipes/object-validation.pipe';
|
||||
|
||||
@ApiTags('connections')
|
||||
@ApiBearerAuth()
|
||||
@Authenticated()
|
||||
@Controller('connections')
|
||||
export class ConnectionController {
|
||||
logger: any;
|
||||
constructor(
|
||||
@Inject(DadosferaLogger)
|
||||
dadosferaLogger: DadosferaLogger,
|
||||
private clientService: ConnectionClientService,
|
||||
) {
|
||||
this.logger = dadosferaLogger.logger;
|
||||
}
|
||||
|
||||
@Post()
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async createConnection(
|
||||
@User() user,
|
||||
@Body(new ValidationPipe()) body: CreateConnectionDto,
|
||||
) {
|
||||
this.logger.info('/connections - Create Connection');
|
||||
|
||||
const { user_id, customer_id, customer_name } = user;
|
||||
|
||||
const response = await this.clientService.createConnection({
|
||||
body,
|
||||
info: { user_id, customer_id, customer_name },
|
||||
});
|
||||
|
||||
delete response.connection.properties;
|
||||
delete response.connection.user_id;
|
||||
delete response.connection.customer_id;
|
||||
delete response.connection.customer_name;
|
||||
delete response.connection.updated_at;
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user