Skip to main content
Glama
base-handler.js1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseTriggerHandler = void 0; const n8n_api_1 = require("../../config/n8n-api"); class BaseTriggerHandler { constructor(client, context) { this.client = client; this.context = context; } validate(input) { return this.inputSchema.parse(input); } getBaseUrl() { if (this.context?.n8nApiUrl) { return this.context.n8nApiUrl.replace(/\/api\/v1\/?$/, ''); } const config = (0, n8n_api_1.getN8nApiConfig)(); if (config?.baseUrl) { return config.baseUrl.replace(/\/api\/v1\/?$/, ''); } return undefined; } getApiKey() { if (this.context?.n8nApiKey) { return this.context.n8nApiKey; } const config = (0, n8n_api_1.getN8nApiConfig)(); return config?.apiKey; } normalizeResponse(result, input, startTime, extra) { const endTime = Date.now(); const duration = endTime - startTime; return { success: true, triggerType: this.triggerType, workflowId: input.workflowId, data: result, metadata: { duration, }, ...extra, }; } errorResponse(input, error, startTime, extra) { const endTime = Date.now(); const duration = endTime - startTime; return { success: false, triggerType: this.triggerType, workflowId: input.workflowId, error, metadata: { duration, }, ...extra, }; } } exports.BaseTriggerHandler = BaseTriggerHandler; //# sourceMappingURL=base-handler.js.map

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/czlonkowski/n8n-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server