*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 {
return {
config,
api: {
registerMethod: (methodName: string, method: RPCMethod): void => {
getRpcServer().registerMethod(pluginName, methodName, method);
},
loadPlugin: getPluginAPI().loadPlugin,
registerMethod: (methodName: string, method: RPCMethod): void => {
getRpcServer().registerMethod(pluginName, methodName, method);
},
loadPlugin: getPluginAPI().loadPlugin,
};
}
}

View File

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