diff --git a/src/plugin.ts b/src/plugin.ts index 99ace98..d8c6208 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,15 +1,15 @@ import { globby } from "globby"; import config from "./config.js"; import { getRpcServer } from "./rpc/server.js"; -import { RelayPluginAPI, RPCMethod, Plugin } from "./types.js"; +import { PluginAPI, RPCMethod, Plugin } from "./types.js"; import slugify from "slugify"; -let pluginApi: PluginAPI; +let pluginApi: PluginApiManager; const sanitizeName = (name: string) => slugify(name, { lower: true, strict: true }); -export class PluginAPI { +export class PluginApiManager { private registeredPlugins: Map = new Map(); public async loadPlugin(moduleName: string): Promise { @@ -47,7 +47,7 @@ export class PluginAPI { return plugin; } - private getPluginAPI(pluginName: string): RelayPluginAPI { + private getPluginAPI(pluginName: string): PluginAPI { return { config, registerMethod: (methodName: string, method: RPCMethod): void => { @@ -58,12 +58,12 @@ export class PluginAPI { } } -export function getPluginAPI(): PluginAPI { +export function getPluginAPI(): PluginApiManager { if (!pluginApi) { - pluginApi = new PluginAPI(); + pluginApi = new PluginApiManager(); } - return pluginApi as PluginAPI; + return pluginApi as PluginApiManager; } export async function loadPlugins() { diff --git a/src/types.ts b/src/types.ts index d39c93e..ace6301 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ import { JSONSchemaType } from "ajv"; -import { PluginAPI } from "./plugin.js"; +import { PluginApiManager } from "./plugin.js"; export interface RPCRequest { bypassCache?: boolean; @@ -55,13 +55,13 @@ export interface StreamFileResponse { done: boolean; } -export interface RelayPluginAPI { +export interface PluginAPI { config: any; registerMethod: (methodName: string, method: RPCMethod) => void; - loadPlugin: PluginAPI["loadPlugin"]; + loadPlugin: PluginApiManager["loadPlugin"]; } -export type PluginFunction = (api: RelayPluginAPI) => Promise; +export type PluginFunction = (api: PluginAPI) => Promise; export interface Plugin { name: string;