*Dont put api methods in an api namespace

This commit is contained in:
Derrick Hammer 2022-08-26 22:12:13 -04:00
parent b91fd5d8b5
commit ba20b1f36e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 9 additions and 9 deletions

View File

@ -50,12 +50,10 @@ export class PluginAPI {
private getPluginAPI(pluginName: string): RelayPluginAPI { private getPluginAPI(pluginName: string): RelayPluginAPI {
return { return {
config, config,
api: { registerMethod: (methodName: string, method: RPCMethod): void => {
registerMethod: (methodName: string, method: RPCMethod): void => { getRpcServer().registerMethod(pluginName, methodName, method);
getRpcServer().registerMethod(pluginName, methodName, method);
},
loadPlugin: getPluginAPI().loadPlugin,
}, },
loadPlugin: getPluginAPI().loadPlugin,
}; };
} }
} }

View File

@ -21,6 +21,7 @@ export interface RPCMethod {
sendStream: (stream: AsyncIterable<Uint8Array>) => void sendStream: (stream: AsyncIterable<Uint8Array>) => void
) => RPCResponse | null; ) => RPCResponse | null;
} }
export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = { export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
anyOf: [], anyOf: [],
oneOf: [], oneOf: [],
@ -48,19 +49,20 @@ export const RPC_REQUEST_SCHEMA: JSONSchemaType<RPCRequest> = {
}, },
}, },
}; };
export interface StreamFileResponse { export interface StreamFileResponse {
data?: Uint8Array; data?: Uint8Array;
done: boolean; done: boolean;
} }
export interface RelayPluginAPI { export interface RelayPluginAPI {
config: any; config: any;
api: { registerMethod: (methodName: string, method: RPCMethod) => void;
registerMethod: (methodName: string, method: RPCMethod) => void; loadPlugin: PluginAPI["loadPlugin"];
loadPlugin: PluginAPI["loadPlugin"];
};
} }
export type PluginFunction = (api: RelayPluginAPI) => Promise<void>; export type PluginFunction = (api: RelayPluginAPI) => Promise<void>;
export interface Plugin { export interface Plugin {
name: string; name: string;
plugin: PluginFunction; plugin: PluginFunction;