UNPKG

@nestjs-mod/two-factor

Version:

Two factor module with an error filter, guard, controller, database migrations and rest-sdk for work with module from other nodejs appliaction

34 lines 1.53 kB
"use strict"; var TwoFactorExceptionsFilter_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.TwoFactorExceptionsFilter = void 0; const tslib_1 = require("tslib"); const common_1 = require("@nestjs/common"); const core_1 = require("@nestjs/core"); const two_factor_errors_1 = require("./two-factor.errors"); let TwoFactorExceptionsFilter = TwoFactorExceptionsFilter_1 = class TwoFactorExceptionsFilter extends core_1.BaseExceptionFilter { constructor() { super(...arguments); this.logger = new common_1.Logger(TwoFactorExceptionsFilter_1.name); } catch(exception, host) { if (exception instanceof two_factor_errors_1.TwoFactorError) { this.logger.error(exception, exception.stack); super.catch(new common_1.HttpException({ code: exception.code, message: exception.message, metadata: exception.metadata, }, common_1.HttpStatus.BAD_REQUEST), host); } else { // eslint-disable-next-line @typescript-eslint/no-explicit-any this.logger.error(exception, exception?.stack); super.catch(exception, host); } } }; exports.TwoFactorExceptionsFilter = TwoFactorExceptionsFilter; exports.TwoFactorExceptionsFilter = TwoFactorExceptionsFilter = TwoFactorExceptionsFilter_1 = tslib_1.__decorate([ (0, common_1.Catch)(two_factor_errors_1.TwoFactorError) ], TwoFactorExceptionsFilter); //# sourceMappingURL=two-factor.filter.js.map