docs: enterprise refactor plan with ralph specs
This commit is contained in:
25
dist/server/notifications/WebhookNotifier.js
vendored
Normal file
25
dist/server/notifications/WebhookNotifier.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/**
|
||||
* WebhookNotifier — posts full anomaly JSON to a generic webhook URL.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WebhookNotifier = void 0;
|
||||
class WebhookNotifier {
|
||||
constructor(webhookUrl) {
|
||||
this.webhookUrl = webhookUrl;
|
||||
}
|
||||
async send(anomaly) {
|
||||
const res = await fetch(this.webhookUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-ABE-Event': 'anomaly.detected',
|
||||
},
|
||||
body: JSON.stringify(anomaly),
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(`Webhook returned ${res.status}: ${await res.text()}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.WebhookNotifier = WebhookNotifier;
|
||||
Reference in New Issue
Block a user