*Add getMethods to RPCServer for plugin api
This commit is contained in:
parent
ad9d838d20
commit
0c577c43bd
|
@ -54,6 +54,7 @@ export class PluginApiManager {
|
|||
getRpcServer().registerMethod(pluginName, methodName, method);
|
||||
},
|
||||
loadPlugin: getPluginAPI().loadPlugin,
|
||||
getMethods: getRpcServer().getMethods,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<void> {
|
||||
(await getDHT("server")).on(
|
||||
"connection",
|
||||
|
|
|
@ -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<void>;
|
||||
|
|
Loading…
Reference in New Issue