Files
n8n-enterprise-unlocked/packages/cli/src/controllers/debug.controller.ts
Iván Ovejero f667b384c9 refactor(core): Standardize filenames in cli (no-changelog) (#10484)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-08-22 11:10:37 +02:00

38 lines
1.3 KiB
TypeScript

import { Get, RestController } from '@/decorators';
import { ActiveWorkflowManager } from '@/active-workflow-manager';
import { OrchestrationService } from '@/services/orchestration.service';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
@RestController('/debug')
export class DebugController {
constructor(
private readonly orchestrationService: OrchestrationService,
private readonly activeWorkflowManager: ActiveWorkflowManager,
private readonly workflowRepository: WorkflowRepository,
) {}
@Get('/multi-main-setup', { skipAuth: true })
async getMultiMainSetupDetails() {
const leaderKey = await this.orchestrationService.multiMainSetup.fetchLeaderKey();
const triggersAndPollers = await this.workflowRepository.findIn(
this.activeWorkflowManager.allActiveInMemory(),
);
const webhooks = await this.workflowRepository.findWebhookBasedActiveWorkflows();
const activationErrors = await this.activeWorkflowManager.getAllWorkflowActivationErrors();
return {
instanceId: this.orchestrationService.instanceId,
leaderKey,
isLeader: this.orchestrationService.isLeader,
activeWorkflows: {
webhooks, // webhook-based active workflows
triggersAndPollers, // poller- and trigger-based active workflows
},
activationErrors,
};
}
}