UNPKG

reservease.consumer

Version:

This package allows you to create an amqplib consumer and producer.

29 lines (28 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SlackNotification = void 0; const SlackMessenger_1 = require("./SlackMessenger"); class SlackNotification extends SlackMessenger_1.SlackMessengerService { constructor(slackToken, slackChannel, devEnviron) { super(slackToken); this.environment = 'production'; this.channel = slackChannel; this.environment = devEnviron; } LogError(err, req, res, next, code = null) { const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl; this.sendMessage(`:x: Error => ${fullUrl} => on: ${new Date()}`, err.message, this.channel); return res.status(400).json({ message: err?.details ? `Validation error: ${err.details.map((x) => x.message).join(', ')} ` : err.message, data: null, code: code ? code : 400, }); } LogSuccess(message, code, data) { return this.sendMessage(`:white_check_mark: Success => ${this.environment} => status: ${code} => message: ${message} => on: ${new Date()}`, data ? JSON.stringify(data) : '', this.channel); } LogDebug(message, data, code) { return this.sendMessage(`:eyes: Debug => ${this.environment} ${code ? ` => status: ${code}` : ''} => message: ${message} => on: ${new Date()}`, data ? JSON.stringify(data) : '', this.channel); } } exports.SlackNotification = SlackNotification;