@sheriff1980/n8n-nodes-comfyuirunner
Version:
An n8n node to run ComfyUI workflows
80 lines • 3.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComfyUiRunner = void 0;
class ComfyUiRunner {
constructor() {
this.description = {
displayName: 'ComfyUI Runner',
name: 'comfyUiRunner',
group: ['External APIs'],
version: 1,
description: 'Runs a ComfyUI workflow via its API',
defaults: {
name: 'ComfyUI Runner',
},
inputs: ['main'],
outputs: ['main'],
properties: [
{
displayName: 'ComfyUI URL',
name: 'comfyUiUrl',
type: 'string',
default: 'http://127.0.0.1:8188',
placeholder: 'http://127.0.0.1:8188',
description: 'The base URL of your running ComfyUI instance (e.g., http://localhost:8188)',
required: true,
},
{
displayName: 'Workflow JSON',
name: 'workflowJson',
type: 'json',
default: '{}',
placeholder: 'Paste your ComfyUI API format workflow here',
description: 'The ComfyUI workflow in API JSON format. Use expressions to insert dynamic data.',
required: true,
},
],
};
}
async execute() {
const items = this.getInputData();
const returnData = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
try {
const comfyUiUrl = this.getNodeParameter('comfyUiUrl', itemIndex, '');
const workflowJsonString = this.getNodeParameter('workflowJson', itemIndex, '{}');
const newItem = {
json: {
...items[itemIndex].json,
_comfyRunnerStatus: 'Placeholder - API call not implemented yet',
_receivedUrl: comfyUiUrl,
_receivedWorkflow: workflowJsonString,
},
binary: {},
pairedItem: { item: itemIndex },
};
returnData.push(newItem);
}
catch (error) {
if (this.continueOnFail()) {
const errorItem = {
json: {
error: error.message,
stack: error.stack,
itemIndex: itemIndex,
inputJson: items[itemIndex].json,
},
binary: {},
pairedItem: { item: itemIndex },
};
returnData.push(errorItem);
continue;
}
throw error;
}
}
return this.prepareOutputData(returnData);
}
}
exports.ComfyUiRunner = ComfyUiRunner;
//# sourceMappingURL=ComfyUiRunner.node.js.map