UPGRADE: Added LOgs lib

This commit is contained in:
rodrigo.zamboni
2022-06-29 10:50:03 -03:00
parent 3c660738f4
commit 9c124be191
20 changed files with 2456 additions and 285 deletions
+22 -14
View File
@@ -5,6 +5,7 @@ import {
Post,
HttpCode,
HttpStatus,
Inject,
} from '@nestjs/common';
import {
AuthSignInRequest,
@@ -19,18 +20,25 @@ import {
} from '@victorradael/protospack';
import { AuthClientService } from 'src/clients/auth/client.service';
import { DadosferaLogger } from 'dadosfera-logs';
import ErrorBuilder from '../../utils/ErrorBuilder';
@Controller('auth')
export class AuthController {
constructor(private authClient: AuthClientService) {}
logger: any;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private authClient: AuthClientService,
) {
this.logger = dadosferaLogger.logger;
}
// DEPRECADO!
@Post()
@HttpCode(HttpStatus.OK)
async signIn_old(@Body() body: AuthSignInRequest) {
console.log(`/auth`, 'SignIn_old');
this.logger.info(`/auth - SignIn_old`);
return this.signIn(body);
}
@@ -38,7 +46,7 @@ export class AuthController {
@Post('login')
@HttpCode(HttpStatus.OK)
async signIn_login(@Body() body: AuthSignInRequest) {
console.log(`/auth`, 'SignIn_login');
this.logger.info(`/auth - SignIn_login`);
return this.signIn(body);
}
@@ -46,7 +54,7 @@ export class AuthController {
@Post('sign-in')
@HttpCode(HttpStatus.OK)
async signIn(@Body() { username, password, totp }: AuthSignInRequest) {
console.log(`/auth`, 'SignIn');
this.logger.info(`/auth - SignIn`);
const tokens = await this.authClient
.signIn({ username, password, totp })
@@ -62,7 +70,7 @@ export class AuthController {
async refreshAccessToken(
@Body() { refreshToken }: AuthRefreshAccessTokenRequest,
) {
console.log(`/auth`, 'RefreshAccessToken');
this.logger.info(`/auth - RefreshAccessToken`);
const accessToken = await this.authClient
.refreshAccessToken({ refreshToken })
@@ -79,7 +87,7 @@ export class AuthController {
@Body() body: AuthEnableTotpMfaRequest,
@Headers() headers,
) {
console.log(`/auth`, 'enable-totp');
this.logger.info(`/auth - enable-totp`);
const { password } = body;
const { authorization: accessToken } = headers;
@@ -99,7 +107,7 @@ export class AuthController {
@Body() body: AuthDisableTotpMfaRequest,
@Headers() headers,
) {
console.log(`/auth`, 'disable-totp');
this.logger.info(`/auth - disable-totp`);
const { password } = body;
const { authorization: accessToken } = headers;
@@ -116,7 +124,7 @@ export class AuthController {
@Post('dismiss-totp')
@HttpCode(HttpStatus.OK)
async dismissTotpMFA(@Headers() headers) {
console.log(`/auth`, 'disable-totp');
this.logger.info(`/auth - disable-totp`);
const { authorization: accessToken } = headers;
@@ -135,7 +143,7 @@ export class AuthController {
@Body() body: AuthVerifyTotpMfaRequest,
@Headers() headers,
): Promise<any> {
console.log(`/auth`, 'enable-totp');
this.logger.info(`/auth - enable-totp`);
const { totp } = body;
const { authorization: accessToken } = headers;
@@ -155,7 +163,7 @@ export class AuthController {
@Body() body: AuthChangePasswordRequest,
@Headers() headers,
): Promise<any> {
console.log(`/auth`, 'change-password');
this.logger.info(`/auth - change-password`);
const { oldPassword, newPassword } = body;
const { authorization: accessToken } = headers;
@@ -176,7 +184,7 @@ export class AuthController {
@Post('reset-password')
@HttpCode(HttpStatus.OK)
async resetPassword(@Body() body: AuthResetPasswordRequest): Promise<any> {
console.log(`/auth`, 'reset-password');
this.logger.info(`/auth - reset-password`);
const { username } = body;
@@ -194,7 +202,7 @@ export class AuthController {
async verifyResetPasswordCode(
@Body() body: AuthVerifyResetPasswordCodeRequest,
): Promise<any> {
console.log(`/auth`, 'verify-reset-password-code');
this.logger.info(`/auth - verify-reset-password-code`);
const { username, code } = body;
@@ -212,7 +220,7 @@ export class AuthController {
async confirmResetPassword(
@Body() body: AuthConfirmResetPasswordRequest,
): Promise<any> {
console.log(`/auth`, 'confirm-reset-password');
this.logger.info(`/auth - confirm-reset-password`);
const { username, code, newPassword } = body;
+127 -32
View File
@@ -3,19 +3,30 @@ import {
Controller,
Delete,
Get,
Inject,
Param,
Post,
Query,
} from '@nestjs/common';
import { CatalogService } from './catalog.service';
import { DadosferaLogger } from 'dadosfera-logs';
@Controller('catalog')
export class CatalogController {
constructor(private catalogService: CatalogService) {}
logger: any;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private catalogService: CatalogService,
) {
this.logger = dadosferaLogger.logger;
}
@Get('all')
async catalogAll(@Body() body) {
console.log(`/catalog`, 'ON CATALOG ALL ROUTE');
this.logger.info(`/catalog - ON CATALOG ALL ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.catalogAll(body);
@@ -24,7 +35,10 @@ export class CatalogController {
@Get('data_apps')
async dataAppsAll(@Body() body) {
console.log(`/catalog`, 'ON FIND ALL DATA APPS ROUTE');
this.logger.info(`/catalog - ON FIND ALL DATA APPS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.dataAppsAll(body);
@@ -33,7 +47,10 @@ export class CatalogController {
@Delete('data_apps/:id')
async dataAppsOne(@Param() params, @Body() body) {
console.log(`/catalog`, 'ON FIND ONE DATA APP ROUTE');
this.logger.info(`/catalog - ON FIND ONE DATA APP ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const { id } = params;
const res = await this.catalogService.dataAppsOne(id, body);
@@ -43,7 +60,10 @@ export class CatalogController {
@Get('dashboard-metabase')
async getAllDashboardMetabase(@Body() body) {
console.log(`/catalog`, 'ON GET ALL DASHBOARDS METABASE ROUTE');
this.logger.info(`/catalog - ON GET ALL DASHBOARDS METABASE ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getAllDashboardMetabase(body);
@@ -53,7 +73,10 @@ export class CatalogController {
@Get('dashboard-metabase/:id')
async getOneDashboardMetabase(@Body() body, @Param() params) {
const { id } = params;
console.log(`/catalog`, 'ON GET ONE DASHBOARD METABASE ROUTE');
this.logger.info(`/catalog - ON GET ONE DASHBOARD METABASE ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getOneDashboardMetabase(id, body);
@@ -62,7 +85,10 @@ export class CatalogController {
@Get('table-metadata')
async getAllTableMetadata(@Body() body, @Query() query) {
console.log(`/catalog`, 'ON GET ALL TABLES METADATA ROUTE');
this.logger.info(`/catalog - ON GET ALL TABLES METADATA ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
if (!query) {
const res = await this.catalogService.getAllTableMetadata(body);
@@ -76,7 +102,10 @@ export class CatalogController {
@Delete('table-metadata/:id')
async deleteOneTableMetadata(@Param() params, @Body() body) {
const { id } = params;
console.log(`/catalog`, 'ON DELETE ONE TABLE METADATA ROUTE');
this.logger.info(`/catalog - ON DELETE ONE TABLE METADATA ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.deleteOneTableMetadata(id, body);
@@ -85,7 +114,10 @@ export class CatalogController {
@Get('column-metadata')
async getOneColumnMetadata(@Body() body, @Query() params) {
console.log(`/catalog`, 'ON GET ONE COLUMN METADATA ROUTE');
this.logger.info(`/catalog - ON GET ONE COLUMN METADATA ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getOneColumnMetadata(body, params);
@@ -94,7 +126,10 @@ export class CatalogController {
@Delete('column-metadata/:id')
async deleteOneColumnMetadata(@Param() params, @Body() body) {
console.log(`/catalog`, 'ON DELETE ONE COLUMN METADATA ROUTE');
this.logger.info(`/catalog - ON DELETE ONE COLUMN METADATA ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const { id } = params;
const res = await this.catalogService.deleteOneColumnMetadata(id, body);
@@ -104,7 +139,10 @@ export class CatalogController {
@Get('data-preview')
async getOneDataPreview(@Body() body, @Query() params) {
console.log(`/catalog`, 'ON GET ONE DATAPREVIEW ROUTE');
this.logger.info(`/catalog - ON GET ONE DATAPREVIEW ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getOneDataPreview(body, params);
@@ -113,7 +151,10 @@ export class CatalogController {
@Get('data-status')
async getDataStatus(@Body() body) {
console.log(`/catalog`, 'ON GET DATA STATUS ROUTE');
this.logger.info(`/catalog - ON GET DATA STATUS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getDataStatus(body);
@@ -122,7 +163,10 @@ export class CatalogController {
@Get('data-status')
async createDataStatus(@Body() body) {
console.log(`/catalog`, 'ON CREATE DATA STATUS ROUTE');
this.logger.info(`/catalog - ON CREATE DATA STATUS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createDataStatus(body);
@@ -131,7 +175,10 @@ export class CatalogController {
@Get('data-description')
async getDataDescription(@Body() body) {
console.log(`/catalog`, 'ON GET DATA DESCRIPTION ROUTE');
this.logger.info(`/catalog - ON GET DATA DESCRIPTION ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getDataDescription(body);
@@ -140,7 +187,10 @@ export class CatalogController {
@Post('data-description')
async createDataDescription(@Body() body) {
console.log(`/catalog`, 'ON CREATE DATA DESCRIPTION ROUTE');
this.logger.info(`/catalog - ON CREATE DATA DESCRIPTION ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createDataDescription(body);
@@ -149,7 +199,10 @@ export class CatalogController {
@Get('data-docs')
async getDataDocs(@Body() body) {
console.log(`/catalog`, 'ON GET DATA DOCS ROUTE');
this.logger.info(`/catalog - ON GET DATA DOCS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getDataDocs(body);
@@ -158,7 +211,10 @@ export class CatalogController {
@Post('data-docs')
async createDataDocs(@Body() body) {
console.log(`/catalog`, 'ON CREATE DATA DOCS ROUTE');
this.logger.info(`/catalog - ON CREATE DATA DOCS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createDataDocs(body);
@@ -167,7 +223,10 @@ export class CatalogController {
@Get('data-rating')
async getDataRating(@Body() body) {
console.log(`/catalog`, 'ON GET DATA RATING ROUTE');
this.logger.info(`/catalog - ON GET DATA RATING ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getDataRating(body);
@@ -176,7 +235,10 @@ export class CatalogController {
@Post('data-rating')
async createDataRating(@Body() body) {
console.log(`/catalog`, 'ON GET DATA RATING ROUTE');
this.logger.info(`/catalog - ON GET DATA RATING ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createDataRating(body);
@@ -185,7 +247,7 @@ export class CatalogController {
@Get('summary-rating/:id')
async getSummaryRating() {
console.log(`/catalog`, 'ON GET SUMMARY RATING ROUTE');
this.logger.info(`/catalog - ON GET SUMMARY RATING ROUTE`);
//const { id } = params;
//
@@ -200,7 +262,10 @@ export class CatalogController {
@Get('data-comment')
async getDataComment(@Body() body) {
console.log(`/catalog`, 'ON GET DATA COMMENT ROUTE');
this.logger.info(`/catalog - ON GET DATA COMMENT ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getDataComment(body);
@@ -209,7 +274,10 @@ export class CatalogController {
@Post('data-comment')
async createDataComment(@Body() body) {
console.log(`/catalog`, 'ON GET DATA COMMENT ROUTE');
this.logger.info(`/catalog - ON GET DATA COMMENT ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createDataComment(body);
@@ -218,7 +286,10 @@ export class CatalogController {
@Get('data-review')
async getDataReview(@Body() body, @Query() params) {
console.log(`/catalog`, 'ON GET DATA REVIEW ROUTE');
this.logger.info(`/catalog - ON GET DATA REVIEW ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getDataReview(body, params);
@@ -227,7 +298,10 @@ export class CatalogController {
@Post('tags')
async createTags(@Body() body) {
console.log(`/catalog`, 'ON CREATE TAG ROUTE');
this.logger.info(`/catalog - ON CREATE TAG ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createTags(body);
@@ -236,7 +310,10 @@ export class CatalogController {
@Get('tags')
async findAllTags(@Body() body) {
console.log(`/catalog`, 'ON FIND ALL TAGS ROUTE');
this.logger.info(`/catalog - ON FIND ALL TAGS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.findAllTags(body);
@@ -245,7 +322,10 @@ export class CatalogController {
@Delete('tags/:id')
async deleteTags(@Param() params, @Body() body) {
console.log(`/catalog`, 'ON DELETE TAG ROUTE');
this.logger.info(`/catalog - ON DELETE TAG ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const { id } = params;
const res = await this.catalogService.deleteTags(id, body);
@@ -255,7 +335,10 @@ export class CatalogController {
@Post('table-tags')
async createTableTags(@Body() body) {
console.log(`/catalog`, 'ON CREATE TABLE TAG ROUTE');
this.logger.info(`/catalog - ON CREATE TABLE TAG ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.createTableTags(body);
@@ -264,7 +347,10 @@ export class CatalogController {
@Get('table-tags')
async getAllTableTags(@Body() body) {
console.log(`/catalog`, 'ON GET ALL TABLE TAGS ROUTE');
this.logger.info(`/catalog - ON GET ALL TABLE TAGS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.findAllTableTags(body);
@@ -273,7 +359,10 @@ export class CatalogController {
@Delete('table-tags/:id')
async deleteTableTags(@Param() params, @Body() body) {
console.log(`/catalog`, 'ON CREATE TABLE TAGS ROUTE');
this.logger.info(`/catalog - ON CREATE TABLE TAGS ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const { id } = params;
const res = await this.catalogService.deleteTableTags(id, body);
@@ -283,7 +372,10 @@ export class CatalogController {
@Get('table-rules')
async getTableRules(@Body() body) {
console.log(`/catalog`, 'ON GET TABLE RULES ROUTE');
this.logger.info(`/catalog - ON GET TABLE RULES ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getTableRules(body);
@@ -292,7 +384,10 @@ export class CatalogController {
@Delete('table-rules/:id')
async deleteTableRules(@Param() params, @Body() body) {
console.log(`/catalog`, 'ON DELETE TABLE RULES ROUTE');
this.logger.info(`/catalog - ON DELETE TABLE RULES ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const { id } = params;
const res = await this.catalogService.deleteTableRules(id, body);
-1
View File
@@ -46,7 +46,6 @@ class CatalogService {
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}`,
);
console.log(data);
// const [, path] = data.iframe_url.split('.dadosfera');
// const host = `httpss://metabase-${body.info.customer.toLowerCase()}.dadosfera.ai`;
+9
View File
@@ -1,4 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Info } from 'src/clients/inputs/interfaces';
export class InputModel {
category: string;
@@ -147,6 +148,8 @@ export class TestConnectionGetColumnsReq {
credentials: CredentialsJdbc;
@ApiPropertyOptional()
id: string;
@ApiPropertyOptional()
info: Info;
}
export class TestConnectionGetColumnsRes {
@ApiProperty()
@@ -158,6 +161,8 @@ export class TestConnectionReq {
plugin: string;
@ApiProperty()
credentials: CredentialsJdbc;
@ApiPropertyOptional()
info: Info;
}
export class TestConnectionRes {
@ApiProperty()
@@ -178,6 +183,8 @@ export class CreateInputReq {
name: string;
@ApiPropertyOptional()
options: InputOptions;
@ApiPropertyOptional()
info: Info;
}
export class Input {
@@ -199,4 +206,6 @@ export class Input {
created_at: string;
@ApiProperty()
updated_at: string;
@ApiPropertyOptional()
info: Info;
}
+39 -10
View File
@@ -3,11 +3,13 @@ import {
Controller,
Delete,
Get,
Inject,
Param,
Patch,
Post,
} from '@nestjs/common';
import { InputsService } from './inputs.service';
import { DadosferaLogger } from 'dadosfera-logs';
import { InputsClientService } from 'src/clients/inputs/client.service';
import { UpdateInputRequest } from 'src/clients/inputs/interfaces';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
@@ -26,7 +28,13 @@ import {
@Controller('inputs')
export class InputsController {
inputService: InputsService;
constructor(private inputsClientService: InputsClientService) {
logger: any;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private inputsClientService: InputsClientService,
) {
this.logger = dadosferaLogger.logger;
this.inputService = new InputsService(this.inputsClientService);
}
@@ -44,7 +52,10 @@ export class InputsController {
@Post('/test-connection')
@ApiOkResponse({ type: TestConnectionRes })
async testConnection(@Body() data: TestConnectionReq) {
console.log(`/test-connection`, 'ON TEST CONNECTION ROUTE');
this.logger.info(`/test-connection - ON TEST CONNECTION ROUTE`, {
user: data.info.user_id,
customer: data.info.customer,
});
const inputService = new InputsService(this.inputsClientService);
const response = await inputService.testConnection(data);
@@ -55,9 +66,12 @@ export class InputsController {
@Post('/test-connection/get-columns')
@ApiOkResponse({ type: TestConnectionGetColumnsRes })
async getColumns(@Body() data: TestConnectionGetColumnsReq) {
console.log(
`/test-connection/get-columns`,
'ON TEST CONNECTION GET COLUMNS ROUTE',
this.logger.info(
`/test-connection/get-columns - ON TEST CONNECTION GET COLUMNS ROUTE`,
{
user: data.info.user_id,
customer: data.info.customer,
},
);
const inputService = new InputsService(this.inputsClientService);
@@ -69,7 +83,10 @@ export class InputsController {
@Post()
@ApiOkResponse({ type: Input })
async create(@Body() createInputDto: CreateInputReq) {
console.log(`/input`, 'ON CREATE ROUTE');
this.logger.info(`/input - ON CREATE ROUTE`, {
user: createInputDto.info.user_id,
customer: createInputDto.info.customer,
});
const inputService = new InputsService(this.inputsClientService);
const response = await inputService.create(createInputDto);
@@ -79,7 +96,10 @@ export class InputsController {
@Get()
async findAll(@Body() body) {
console.log(`/input`, 'ON FIND ALL ROUTE');
this.logger.info(`/input - ON FIND ALL ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const inputService = new InputsService(this.inputsClientService);
@@ -91,7 +111,10 @@ export class InputsController {
@Get('/:id')
async findOne(@Body() body, @Param() params) {
const { id } = params;
console.log(`/input/${id}`, 'ON FIND ONE ROUTE');
this.logger.info(`/input/${id} - ON FIND ONE ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const inputService = new InputsService(this.inputsClientService);
const response = await inputService.findOne({ id, ...body });
@@ -105,7 +128,10 @@ export class InputsController {
const { info } = updateInputDto;
delete updateInputDto.info;
console.log(`/input/${id}`, 'ON UPDATE ROUTE');
this.logger.info(`/input/${id} - ON UPDATE ROUTE`, {
user: updateInputDto.info.user_id,
customer: updateInputDto.info.costumer_id,
});
const inputService = new InputsService(this.inputsClientService);
const response = await inputService.update(id, updateInputDto, info);
@@ -117,7 +143,10 @@ export class InputsController {
async delete(@Body() data, @Param() params) {
const { id } = params;
console.log(`/input/${id}`, 'ON DELETE ROUTE');
this.logger.info(`/input/${id} - ON DELETE ROUTE`, {
user: data.info.user_id,
customer: data.info.customer,
});
const inputService = new InputsService(this.inputsClientService);
+33 -7
View File
@@ -3,6 +3,7 @@ import {
Controller,
Delete,
Get,
Inject,
Param,
Post,
Put,
@@ -10,14 +11,24 @@ import {
import { Payload } from '@nestjs/microservices';
import { OutputsClientService } from 'src/clients/outputs/client.service';
import { OutputsService } from './outputs.service';
import { DadosferaLogger } from 'dadosfera-logs';
@Controller('outputs')
export class OutputsController {
constructor(private outputsClientService: OutputsClientService) {}
logger: any;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private outputsClientService: OutputsClientService,
) {
this.logger = dadosferaLogger.logger;
}
@Post()
async create(@Body() createOutputDto) {
console.log(process.env.DEV_URL + `/output`, 'ON CREATE ROUTE');
this.logger.info(process.env.DEV_URL + `/output - ON CREATE ROUTE`, {
user: createOutputDto.info.user_id,
customer: createOutputDto.info.customer,
});
const outputService = new OutputsService(this.outputsClientService);
const response = await outputService.create(createOutputDto);
@@ -27,7 +38,10 @@ export class OutputsController {
@Get()
async findAll(@Body() data) {
console.log(process.env.DEV_URL + `/output`, 'ON Find All ROUTE');
this.logger.info(process.env.DEV_URL + `/output - ON Find All ROUTE`, {
user: data.info.user_id,
customer: data.info.customer,
});
const outputService = new OutputsService(this.outputsClientService);
const response = await outputService.findAll(data);
@@ -38,7 +52,13 @@ export class OutputsController {
@Get('/:id')
async findOne(@Body() data, @Param() params) {
const { id } = params;
console.log(process.env.DEV_URL + `/output/${id}`, 'ON Find One ROUTE');
this.logger.info(
process.env.DEV_URL + `/output/${id} - ON Find One ROUTE`,
{
user: data.info.user_id,
customer: data.info.customer,
},
);
const outputService = new OutputsService(this.outputsClientService);
const response = await outputService.findOne({ id, ...data });
@@ -52,7 +72,10 @@ export class OutputsController {
const { info } = updateOutputDto;
delete updateOutputDto.info;
console.log(process.env.DEV_URL + `/output/${id}`, 'ON UPDATE ROUTE');
this.logger.info(process.env.DEV_URL + `/output/${id} - ON UPDATE ROUTE`, {
user: updateOutputDto.info.user_id,
customer: updateOutputDto.info.customer,
});
const outputService = new OutputsService(this.outputsClientService);
const response = await outputService.update(id, updateOutputDto, info);
@@ -63,7 +86,10 @@ export class OutputsController {
@Delete(':id')
async delete(@Body() data, @Param() params) {
const { id } = params;
console.log(process.env.DEV_URL + `/output/${id}`, 'ON DELETE ROUTE');
this.logger.info(process.env.DEV_URL + `/output/${id} - ON DELETE ROUTE`, {
user: data.info.user_id,
customer: data.info.customer,
});
const outputService = new OutputsService(this.outputsClientService);
const response = await outputService.remove({ id, ...data });
+30 -15
View File
@@ -3,25 +3,37 @@ import {
Controller,
Delete,
Get,
Inject,
Param,
Post,
Put,
} from '@nestjs/common';
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
import { PipelinesService } from './pipelines.service';
import { DadosferaLogger } from 'dadosfera-logs';
@Controller('pipelines')
export class PipelinesController {
constructor(private pipelinesClientService: PipelinesClientService) {}
logger: any;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private pipelinesClientService: PipelinesClientService,
) {
this.logger = dadosferaLogger.logger;
}
@Post('start/:id')
async activate(@Param() params, @Body() body) {
const { id } = params;
const { info } = body;
console.log(
process.env.DEV_URL + `/pipeline/start/${id}`,
'ON START PIPELINE ROUTE',
this.logger.info(
process.env.DEV_URL + `/pipeline/start/${id} - ON START PIPELINE ROUTE`,
{
user: body.info.user_id,
customer: body.info.customer,
},
);
const pipelineService = new PipelinesService(this.pipelinesClientService);
@@ -35,9 +47,12 @@ export class PipelinesController {
const { id } = params;
body.id = id;
console.log(
process.env.DEV_URL + `/pipeline/${id}`,
'ON GET PIPELINE STATUS ROUTE',
this.logger.info(
process.env.DEV_URL + `/pipeline/${id} - ON GET PIPELINE STATUS ROUTE`,
{
user: body.info.user_id,
customer: body.info.customer,
},
);
const pipelineService = new PipelinesService(this.pipelinesClientService);
@@ -49,9 +64,9 @@ export class PipelinesController {
@Get(':id/:details')
async getPipelineLogs(@Param() params) {
const { id, details } = params;
console.log(
process.env.DEV_URL + `/pipeline/${id}`,
'ON GET PIPELINE LOGS ROUTE',
this.logger.info(
process.env.DEV_URL + `/pipeline/${id} - ON GET PIPELINE LOGS ROUTE`,
{},
);
const pipelineService = new PipelinesService(this.pipelinesClientService);
@@ -62,7 +77,7 @@ export class PipelinesController {
@Post()
async create(@Body() createPipelineDto) {
console.log(process.env.DEV_URL + `/pipelines`, 'ON CREATE ROUTE');
this.logger.info(process.env.DEV_URL + `/pipelines ON CREATE ROUTE`);
const pipelineService = new PipelinesService(this.pipelinesClientService);
const response = await pipelineService.create(createPipelineDto);
@@ -72,7 +87,7 @@ export class PipelinesController {
@Get()
async findAll(@Body() data) {
console.log(process.env.DEV_URL + `/pipeline`, 'ON Find All ROUTE');
this.logger.info(process.env.DEV_URL + `/pipeline ON Find All ROUTE`);
const pipelineService = new PipelinesService(this.pipelinesClientService);
const response = await pipelineService.findAll(data);
@@ -83,7 +98,7 @@ export class PipelinesController {
@Get('/:id')
async findOne(@Body() data, @Param() params) {
const { id } = params;
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON Find One ROUTE');
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON Find One ROUTE`);
const pipelineService = new PipelinesService(this.pipelinesClientService);
const response = await pipelineService.findOne({ id, ...data });
@@ -97,7 +112,7 @@ export class PipelinesController {
const { info } = updatePipelineDto;
delete updatePipelineDto.info;
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON UPDATE ROUTE');
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON UPDATE ROUTE`);
const pipelineService = new PipelinesService(this.pipelinesClientService);
const response = await pipelineService.update(id, updatePipelineDto, info);
@@ -108,7 +123,7 @@ export class PipelinesController {
@Delete(':id')
async delete(@Body() data, @Param() params) {
const { id } = params;
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON DELETE ROUTE');
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON DELETE ROUTE`);
const pipelineService = new PipelinesService(this.pipelinesClientService);
const response = await pipelineService.remove({ id, ...data });
@@ -3,6 +3,7 @@ import {
Controller,
Delete,
Get,
Inject,
Param,
Post,
Put,
@@ -11,16 +12,27 @@ import { Payload } from '@nestjs/microservices';
import { TransformationsClientService } from 'src/clients/transformations/client.service';
import { IIdRequest } from 'src/clients/transformations/interfaces';
import { TransformationsService } from './transformations.service';
import { DadosferaLogger } from 'dadosfera-logs';
@Controller('transformations')
export class TransformationsController {
logger: any;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private transformationsClientService: TransformationsClientService,
) {}
) {
this.logger = dadosferaLogger.logger;
}
@Post()
async create(@Body() createTransformationDto) {
console.log(process.env.DEV_URL + `/transformation`, 'ON CREATE ROUTE');
this.logger.info(
process.env.DEV_URL + `/transformation - ON CREATE ROUTE`,
{
user: createTransformationDto.info.user_id,
customer: createTransformationDto.info.customer,
},
);
const transformationService = new TransformationsService(
this.transformationsClientService,
@@ -34,7 +46,13 @@ export class TransformationsController {
@Get()
async findAll(@Body() data: IIdRequest) {
console.log(process.env.DEV_URL + `/transformation`, 'ON Find All ROUTE');
this.logger.info(
process.env.DEV_URL + `/transformation - ON Find All ROUTE`,
{
user: data.info.user_id,
customer: data.info.customer_id,
},
);
const transformationService = new TransformationsService(
this.transformationsClientService,
@@ -47,9 +65,12 @@ export class TransformationsController {
@Get('/:id')
async findOne(@Body() data, @Param() params) {
const { id } = params;
console.log(
process.env.DEV_URL + `/transformation/${id}`,
'ON Find One ROUTE',
this.logger.info(
process.env.DEV_URL + `/transformation/${id} - ON Find One ROUTE`,
{
user: data.info.user_id,
customer: data.info.customer,
},
);
const transformationService = new TransformationsService(
@@ -63,9 +84,12 @@ export class TransformationsController {
@Put(':id')
async update(@Payload() updateTransformationDto, @Param() params) {
const { id } = params;
console.log(
process.env.DEV_URL + `/transformation/${id}`,
'ON UPDATE ROUTE',
this.logger.info(
process.env.DEV_URL + `/transformation/${id} - ON UPDATE ROUTE`,
{
user: updateTransformationDto.info.user_id,
customer: updateTransformationDto.info.customer,
},
);
const transformationService = new TransformationsService(
@@ -82,9 +106,12 @@ export class TransformationsController {
@Delete(':id')
async delete(@Body() data, @Param() params) {
const { id } = params;
console.log(
process.env.DEV_URL + `/transformation/${id}`,
'ON DELETE ROUTE',
this.logger.info(
process.env.DEV_URL + `/transformation/${id} - ON DELETE ROUTE`,
{
user: data.info.user_id,
customer: data.info.customer,
},
);
const transformationService = new TransformationsService(