node-red-contrib-home-assistant-websocket
Version:
Node-RED integration with Home Assistant through websocket and REST API
33 lines (32 loc) • 1.26 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const BidrectionalIntegration_1 = __importDefault(require("../../common/integration/BidrectionalIntegration"));
const Integration_1 = require("../../common/integration/Integration");
class WebhookIntegration extends BidrectionalIntegration_1.default {
getDiscoveryPayload() {
const methods = [
'method_post',
'method_get',
'method_put',
'method_head',
];
const allowedMethods = methods.reduce((acc, method) => {
if (this.node.config[method]) {
acc.push(method.replace('method_', '').toUpperCase());
}
return acc;
}, []);
return {
type: Integration_1.MessageType.Webhook,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
server_id: this.node.config.server,
webhook_id: this.node.config.webhookId,
name: this.node.config.id,
allowed_methods: allowedMethods,
};
}
}
exports.default = WebhookIntegration;
;