26 lines
759 B
JavaScript
26 lines
759 B
JavaScript
"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;
|