diff --git a/src/plugin.ts b/src/plugin.ts index d8c6208..768dfc2 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -54,6 +54,7 @@ export class PluginApiManager { getRpcServer().registerMethod(pluginName, methodName, method); }, loadPlugin: getPluginAPI().loadPlugin, + getMethods: getRpcServer().getMethods, }; } } diff --git a/src/rpc/server.ts b/src/rpc/server.ts index 3454b30..1a74363 100644 --- a/src/rpc/server.ts +++ b/src/rpc/server.ts @@ -64,6 +64,18 @@ export class RPCServer { methodMap.set(methodName, options); } + public getMethods(): string[] { + const methods = []; + + for (const module in this.methods) { + for (const method in this.methods.get(module)) { + methods.push(`${module}.${method}`); + } + } + + return methods; + } + private async init(): Promise { (await getDHT("server")).on( "connection", diff --git a/src/types.ts b/src/types.ts index 4f267e6..e58009b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,6 @@ import { JSONSchemaType } from "ajv"; import { PluginApiManager } from "./plugin.js"; +import { RPCServer } from "./rpc/server.js"; export interface RPCRequest { bypassCache?: boolean; @@ -59,6 +60,7 @@ export interface PluginAPI { config: any; registerMethod: (methodName: string, method: RPCMethod) => void; loadPlugin: PluginApiManager["loadPlugin"]; + getMethods: RPCServer["getMethods"]; } export type PluginFunction = (api: PluginAPI) => Promise;