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
+20 -14
View File
@@ -1,4 +1,4 @@
import { Logger, OnModuleInit, Inject } from '@nestjs/common';
import { OnModuleInit, Inject } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { DadosferaLogger } from 'dadosfera-logs';
@@ -31,10 +31,16 @@ import {
import grpcHandler from '../../utils/grpcHandler';
export class AuthClientService implements OnModuleInit {
private readonly logger = new Logger(AuthClientService.name);
logger: any;
private authService: AuthServiceInterface;
constructor(@Inject('DUC_PACKAGE') private readonly grpcClient: ClientGrpc) {}
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
@Inject('DUC_PACKAGE') private readonly grpcClient: ClientGrpc,
) {
this.logger = dadosferaLogger.logger;
}
onModuleInit() {
this.authService = this.grpcClient.getService<AuthServiceInterface>(
@@ -43,7 +49,7 @@ export class AuthClientService implements OnModuleInit {
}
async getPublicKeys() {
this.logger.log('GetPublicKeys');
this.logger.info('GetPublicKeys');
return grpcHandler<AuthGetPublicKeysResponse>(
this.authService.AuthGetPublicKeys({}),
@@ -51,7 +57,7 @@ export class AuthClientService implements OnModuleInit {
}
async signIn({ username, password, totp }: AuthSignInRequest) {
this.logger.log('SignIn');
this.logger.info('SignIn');
return grpcHandler<AuthSignInResponse>(
this.authService.AuthSignIn({ username, password, totp }),
@@ -59,7 +65,7 @@ export class AuthClientService implements OnModuleInit {
}
async refreshAccessToken({ refreshToken }: AuthRefreshAccessTokenRequest) {
this.logger.log('RefreshAccessToken');
this.logger.info('RefreshAccessToken');
return grpcHandler<AuthRefreshAccessTokenResponse>(
this.authService.AuthRefreshAccessToken({ refreshToken }),
@@ -71,7 +77,7 @@ export class AuthClientService implements OnModuleInit {
oldPassword,
newPassword,
}: AuthChangePasswordRequest) {
this.logger.log('ChangePassword');
this.logger.info('ChangePassword');
return grpcHandler<AuthChangePasswordResponse>(
this.authService.AuthChangePassword({
@@ -83,7 +89,7 @@ export class AuthClientService implements OnModuleInit {
}
async resetPassword({ username }: AuthResetPasswordRequest) {
this.logger.log('resetPassword');
this.logger.info('resetPassword');
return grpcHandler<AuthResetPasswordResponse>(
this.authService.AuthResetPassword({ username }),
@@ -94,7 +100,7 @@ export class AuthClientService implements OnModuleInit {
username,
code,
}: AuthVerifyResetPasswordCodeRequest) {
this.logger.log('verifyResetPasswordCode');
this.logger.info('verifyResetPasswordCode');
return grpcHandler<AuthVerifyResetPasswordCodeResponse>(
this.authService.AuthVerifyResetPasswordCode({ username, code }),
@@ -106,7 +112,7 @@ export class AuthClientService implements OnModuleInit {
code,
newPassword,
}: AuthConfirmResetPasswordRequest) {
this.logger.log('confirmResetPassword');
this.logger.info('confirmResetPassword');
return grpcHandler<AuthConfirmResetPasswordResponse>(
this.authService.AuthConfirmResetPassword({
@@ -118,7 +124,7 @@ export class AuthClientService implements OnModuleInit {
}
async enableTotpMFA({ accessToken, password }: AuthEnableTotpMfaRequest) {
this.logger.log('enableTotpMFA');
this.logger.info('enableTotpMFA');
return grpcHandler<AuthEnableTotpMfaResponse>(
this.authService.AuthEnableTotpMfa({ accessToken, password }),
@@ -126,7 +132,7 @@ export class AuthClientService implements OnModuleInit {
}
async disableTotpMFA({ accessToken, password }: AuthDisableTotpMfaRequest) {
this.logger.log('disableTotpMFA');
this.logger.info('disableTotpMFA');
return grpcHandler<AuthDisableTotpMfaResponse>(
this.authService.AuthDisableTotpMfa({ accessToken, password }),
@@ -134,7 +140,7 @@ export class AuthClientService implements OnModuleInit {
}
async dismissTotpMFA({ accessToken }: AuthDismissTotpMfaRequest) {
this.logger.log('dismissTotpMFA');
this.logger.info('dismissTotpMFA');
return grpcHandler<AuthDismissTotpMfaResponse>(
this.authService.AuthDismissTotpMfa({ accessToken }),
@@ -142,7 +148,7 @@ export class AuthClientService implements OnModuleInit {
}
async verifyTotp({ accessToken, totp }: AuthVerifyTotpMfaRequest) {
this.logger.log('disableTotpMFA');
this.logger.info('disableTotpMFA');
return grpcHandler<AuthVerifyTotpMfaResponse>(
this.authService.AuthVerifyTotpMfa({ accessToken, totp }),