mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-03 02:07:06 +02:00
27 lines
770 B
TypeScript
27 lines
770 B
TypeScript
import type { InstanceRegistration } from '@n8n/api-types';
|
|
import { Service } from '@n8n/di';
|
|
|
|
export interface InstanceRegistryProvider {
|
|
getAllInstances(): Promise<InstanceRegistration[]>;
|
|
getLocalInstance(): InstanceRegistration | null;
|
|
}
|
|
|
|
@Service()
|
|
export class InstanceRegistryProxyService implements InstanceRegistryProvider {
|
|
private provider: InstanceRegistryProvider | null = null;
|
|
|
|
registerProvider(provider: InstanceRegistryProvider): void {
|
|
this.provider = provider;
|
|
}
|
|
|
|
async getAllInstances(): Promise<InstanceRegistration[]> {
|
|
if (!this.provider) return [];
|
|
return await this.provider.getAllInstances();
|
|
}
|
|
|
|
getLocalInstance(): InstanceRegistration | null {
|
|
if (!this.provider) return null;
|
|
return this.provider.getLocalInstance();
|
|
}
|
|
}
|