FEAT: Connection test creating connection

- If any error occurs, connection is deleted
 - If operation_result is false, connection is deleted
This commit is contained in:
Gabriel Rosa
2022-08-03 11:31:57 -03:00
parent a1cdad42ab
commit 688bf49f3b
11 changed files with 201 additions and 124 deletions
@@ -5,6 +5,7 @@ import {
HttpStatus,
Inject,
Post,
UseFilters,
ValidationPipe,
} from '@nestjs/common';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
@@ -24,9 +25,11 @@ import {
} from './dto/connection-test';
import { DadosferaLogger } from 'dadosfera-logs';
import { Authenticated } from 'src/authentication/authentication.decorator';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
@ApiTags('Connection Test')
@Controller('connection-test')
@UseFilters(new GrpcToHttpExceptionFilter())
@Authenticated()
export class ConnectionTestController {
logger: any;
@@ -60,16 +63,13 @@ export class ConnectionTestController {
@HttpCode(HttpStatus.OK)
async connectionTestCredentials(
@User() user: RequestUser,
@Body(new ValidationPipe()) body: ConnectionTestCredentialsReq,
@Body() body: ConnectionTestCredentialsReq,
) {
this.logger.info('/connection-test/credentials', {
user: user.user_id,
customer: user.customer_name,
});
return this.connectionTestService.connectionTestCredentials(
body,
user.customer_name,
);
return this.connectionTestService.connectionTestCredentials(body, user);
}
@Post('schemas')
@@ -113,7 +113,7 @@ export class ConnectionTestController {
@User() user: RequestUser,
@Body(new ValidationPipe()) body: GetTableMetadataReq,
) {
this.logger.info('/connection-test/tables', {
this.logger.info('/connection-test/table-metadata', {
user: user.user_id,
customer: user.customer_name,
});