feature(dashboard): add integrations and notifications

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-10-02 22:12:05 +02:00
parent d920f6951c
commit f65a633403
94 changed files with 3692 additions and 127 deletions

View File

@@ -0,0 +1,34 @@
// Cred to (@OpenStatusHQ) https://github.com/openstatusHQ/openstatus/blob/main/packages/notifications/discord/src/index.ts
export function sendDiscordNotification({
webhookUrl,
message,
}: {
webhookUrl: string;
message: string;
}) {
return fetch(webhookUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: message,
avatar_url: 'https://openpanel.dev/logo.jpg',
username: 'OpenPanel Notifications',
}),
}).catch((err) => {
return {
ok: false,
json: () => Promise.resolve({}),
};
});
}
export function sendTestDiscordNotification(webhookUrl: string) {
return sendDiscordNotification({
webhookUrl,
message:
'**🧪 Test [OpenPanel.dev](<https://openpanel.dev/>)**\nIf you can read this, your Slack webhook is functioning correctly!\n',
});
}