mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-07 05:53:07 +00:00
chore: add pre-built dist folder for npx usage
This commit is contained in:
committed by
Romuald Członkowski
parent
a70d96a373
commit
5057481e70
60
dist/triggers/handlers/base-handler.js
vendored
Normal file
60
dist/triggers/handlers/base-handler.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"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
|
||||
Reference in New Issue
Block a user