From 3ac8e38f665539f7a8b1dee6891d5c7fb6feae37 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 18 Apr 2023 22:47:09 -0400 Subject: [PATCH] *Add app getter method to api --- src/modules/app.ts | 4 ++++ src/modules/plugin.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/modules/app.ts b/src/modules/app.ts index b6a66b8..fd33979 100644 --- a/src/modules/app.ts +++ b/src/modules/app.ts @@ -19,3 +19,7 @@ export async function start() { await app.listen({ port: config.uint("core.appport"), host: "0.0.0.0" }); } + +export function get(): FastifyInstance { + return app; +} diff --git a/src/modules/plugin.ts b/src/modules/plugin.ts index 55acc9b..8ed955c 100644 --- a/src/modules/plugin.ts +++ b/src/modules/plugin.ts @@ -17,6 +17,7 @@ import { ProtocolManager, } from "./swarm.js"; import { get as getSSl, SSLManager } from "./ssl.js"; +import { get as getApp } from "./app.js"; import type { HDKey } from "micro-ed25519-hdkey"; import corePlugins from "../plugins"; import Util from "./plugin/util"; @@ -95,6 +96,10 @@ class PluginAPI extends EventEmitter2 { return getProtocolManager(); } + get app() { + return getApp(); + } + public loadPlugin( moduleName: string ): (moduleName: string) => Promise {