*Refactor how core plugins are loaded
This commit is contained in:
parent
5c85ad2962
commit
ce23f0a7b8
|
@ -8,9 +8,6 @@ import path from "path";
|
||||||
import type { Logger } from "pino";
|
import type { Logger } from "pino";
|
||||||
|
|
||||||
import { getHDKey, getSeed } from "../lib/seed.js";
|
import { getHDKey, getSeed } from "../lib/seed.js";
|
||||||
import pluginRpc from "../plugins/rpc";
|
|
||||||
import pluginCore from "../plugins/core";
|
|
||||||
import pluginDht from "../plugins/dht";
|
|
||||||
import type Config from "@lumeweb/cfg";
|
import type Config from "@lumeweb/cfg";
|
||||||
import EventEmitter2 from "eventemitter2";
|
import EventEmitter2 from "eventemitter2";
|
||||||
import log from "../log.js";
|
import log from "../log.js";
|
||||||
|
@ -21,6 +18,7 @@ import {
|
||||||
} from "./swarm.js";
|
} from "./swarm.js";
|
||||||
import { get as getSSl, SSLManager } from "./ssl.js";
|
import { get as getSSl, SSLManager } from "./ssl.js";
|
||||||
import type { HDKey } from "micro-ed25519-hdkey";
|
import type { HDKey } from "micro-ed25519-hdkey";
|
||||||
|
import corePlugins from "../plugins";
|
||||||
|
|
||||||
let pluginAPIManager: PluginAPIManager;
|
let pluginAPIManager: PluginAPIManager;
|
||||||
let pluginAPI: PluginAPI;
|
let pluginAPI: PluginAPI;
|
||||||
|
@ -228,9 +226,9 @@ export function getPluginAPIManager(): PluginAPIManager {
|
||||||
export async function loadPlugins() {
|
export async function loadPlugins() {
|
||||||
const apiManager = getPluginAPIManager();
|
const apiManager = getPluginAPIManager();
|
||||||
|
|
||||||
apiManager.loadPluginInstance(pluginCore);
|
for (const plugin of corePlugins) {
|
||||||
apiManager.loadPluginInstance(pluginRpc);
|
await apiManager.loadPluginInstance(plugin);
|
||||||
apiManager.loadPluginInstance(pluginDht);
|
}
|
||||||
|
|
||||||
for (const plugin of [...new Set(config.array("plugins", []))] as []) {
|
for (const plugin of [...new Set(config.array("plugins", []))] as []) {
|
||||||
await apiManager.loadPlugin(plugin);
|
await apiManager.loadPlugin(plugin);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import core from "./core";
|
||||||
|
import rpc from "./rpc";
|
||||||
|
import dht from "./dht";
|
||||||
|
|
||||||
|
const corePlugins = [core, dht, rpc];
|
||||||
|
|
||||||
|
export default corePlugins;
|
Loading…
Reference in New Issue