UPDATE: Added log-lib on more routes and services

This commit is contained in:
rodrigo.zamboni
2022-06-29 14:12:13 -03:00
parent bc0d456c2a
commit a39622bfa1
11 changed files with 222 additions and 132 deletions
+7 -3
View File
@@ -4,11 +4,12 @@ import {
OnApplicationBootstrap,
ExecutionContext,
Logger,
Inject,
} from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import assert from 'assert';
import jwt from 'jsonwebtoken';
import { DadosferaLogger } from 'dadosfera-logs';
import { AuthClientService } from '../clients/auth/client.service';
import { Permission } from './permissions.enum';
import {
@@ -24,15 +25,18 @@ import ErrorCodes from '../utils/errorCodes';
export class AuthenticationGuard
implements CanActivate, OnApplicationBootstrap
{
private readonly logger = new Logger(AuthenticationGuard.name);
logger: any;
pems: Map<string, string>;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private reflector: Reflector,
private authClient: AuthClientService,
) {
this.pems = new Map();
this.logger = dadosferaLogger.logger;
}
async onApplicationBootstrap() {
@@ -125,7 +129,7 @@ export class AuthenticationGuard
} catch (err) {
// log errors if authentication is required
if (mustBeAuthenticated) {
this.logger.log('Unable to verify duc access token\n' + err.stack);
this.logger.error('Unable to verify duc access token\n' + err.stack);
}
return false;