Initial commit: Angular frontend and Expressjs backend

This commit is contained in:
chamikaJ
2024-05-17 09:32:30 +05:30
parent eb0a0d77d6
commit 298ca6beeb
3548 changed files with 193558 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
import axios from "axios";
import {isProduction, log_error} from "./utils";
export async function send_to_slack(error: any) {
if (!isProduction()) return;
if (!process.env.SLACK_WEBHOOK) return;
try {
const url = process.env.SLACK_WEBHOOK;
const blocks = [];
const title = error.message || "Error";
blocks.push({
"type": "header",
"text": {
"type": "plain_text",
"text": title,
"emoji": true
}
});
blocks.push({
type: "section",
text: {
type: "mrkdwn",
text: `\`\`\`\n${JSON.stringify(error)}\`\`\``
}
});
const request = {blocks};
await axios.post(url, JSON.stringify(request));
} catch (e) {
log_error(e);
}
}