UNPKG

n8n-nodes-selfhosthub

Version:

Collection of n8n nodes for self-hosted AI services, including Leonardo.ai integration for AI image and content generation capabilities.

62 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildWebhookObject = buildWebhookObject; exports.buildWebhookExports = buildWebhookExports; exports.isValidWebhookUrl = isValidWebhookUrl; exports.sanitizeWebhookUrl = sanitizeWebhookUrl; /** * Builds webhook object for JSON2Video API * Returns undefined if no webhook URL is provided */ function buildWebhookObject(webhookUrl) { if (!webhookUrl || typeof webhookUrl !== 'string' || webhookUrl.trim() === '') { return undefined; } return { url: webhookUrl.trim(), }; } /** * Builds webhook object in exports format for JSON2Video API * This is used in basic mode for some operations */ function buildWebhookExports(webhookUrl) { if (!webhookUrl || typeof webhookUrl !== 'string' || webhookUrl.trim() === '') { return undefined; } return [{ destinations: [{ type: 'webhook', endpoint: webhookUrl.trim() }] }]; } /** * Validates webhook URL format */ function isValidWebhookUrl(url) { if (!url || typeof url !== 'string') { return false; } try { const parsed = new URL(url.trim()); return parsed.protocol === 'http:' || parsed.protocol === 'https:'; } catch (error) { return false; } } /** * Sanitizes webhook URL by trimming whitespace and validating format */ function sanitizeWebhookUrl(url) { if (!url || typeof url !== 'string') { return null; } const trimmed = url.trim(); if (!isValidWebhookUrl(trimmed)) { return null; } return trimmed; } //# sourceMappingURL=webhookUtils.js.map