*Dont put api methods in an api namespace
This commit is contained in:
parent
b91fd5d8b5
commit
ba20b1f36e
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
10
src/types.ts
10
src/types.ts
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue