From c213b21bee07cea9e64a23d28dd55addee5d5a97 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Mon, 5 Aug 2024 16:59:21 -0400 Subject: [PATCH] move: BroadcastService to [+] BroadcastModule --- src/backend/exports.js | 2 ++ src/backend/src/CoreModule.js | 3 --- .../src/modules/broadcast/BroadcastModule.js | 14 ++++++++++++++ .../broadcast}/BroadcastService.js | 4 +--- tools/run-selfhosted.js | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 src/backend/src/modules/broadcast/BroadcastModule.js rename src/backend/src/{services => modules/broadcast}/BroadcastService.js (98%) diff --git a/src/backend/exports.js b/src/backend/exports.js index 28c7a266..0ed27f99 100644 --- a/src/backend/exports.js +++ b/src/backend/exports.js @@ -27,6 +27,7 @@ const BaseService = require("./src/services/BaseService.js"); const { Context } = require("./src/util/context.js"); const { TestDriversModule } = require("./src/modules/test-drivers/TestDriversModule.js"); const { PuterAIModule } = require("./src/modules/puterai/PuterAIModule.js"); +const { BroadcastModule } = require("./src/modules/broadcast/BroadcastModule.js"); module.exports = { @@ -50,4 +51,5 @@ module.exports = { SelfHostedModule, TestDriversModule, PuterAIModule, + BroadcastModule, }; diff --git a/src/backend/src/CoreModule.js b/src/backend/src/CoreModule.js index ef875add..8110acf6 100644 --- a/src/backend/src/CoreModule.js +++ b/src/backend/src/CoreModule.js @@ -279,9 +279,6 @@ const install = async ({ services, app, useapi }) => { const { ScriptService } = require('./services/ScriptService'); services.registerService('script', ScriptService); - const { BroadcastService } = require('./services/BroadcastService'); - services.registerService('broadcast', BroadcastService); - const { NotificationService } = require('./services/NotificationService'); services.registerService('notification', NotificationService); diff --git a/src/backend/src/modules/broadcast/BroadcastModule.js b/src/backend/src/modules/broadcast/BroadcastModule.js new file mode 100644 index 00000000..f7d0dc06 --- /dev/null +++ b/src/backend/src/modules/broadcast/BroadcastModule.js @@ -0,0 +1,14 @@ +const { AdvancedBase } = require("@heyputer/puter-js-common"); + +class BroadcastModule extends AdvancedBase { + async install (context) { + const services = context.get('services'); + + const { BroadcastService } = require('./BroadcastService'); + services.registerService('broadcast', BroadcastService); + } +} + +module.exports = { + BroadcastModule, +}; diff --git a/src/backend/src/services/BroadcastService.js b/src/backend/src/modules/broadcast/BroadcastService.js similarity index 98% rename from src/backend/src/services/BroadcastService.js rename to src/backend/src/modules/broadcast/BroadcastService.js index 597228d1..0b393dff 100644 --- a/src/backend/src/services/BroadcastService.js +++ b/src/backend/src/modules/broadcast/BroadcastService.js @@ -17,9 +17,7 @@ * along with this program. If not, see . */ const { AdvancedBase } = require("@heyputer/puter-js-common"); -const { Endpoint } = require("../util/expressutil"); -const { UserActorType } = require("./auth/Actor"); -const BaseService = require("./BaseService"); +const BaseService = require("../../services/BaseService"); class KeyPairHelper extends AdvancedBase { static MODULES = { diff --git a/tools/run-selfhosted.js b/tools/run-selfhosted.js index 8c4cb178..9253b21e 100644 --- a/tools/run-selfhosted.js +++ b/tools/run-selfhosted.js @@ -84,6 +84,7 @@ const main = async () => { DatabaseModule, LocalDiskStorageModule, SelfHostedModule, + BroadcastModule, TestDriversModule, PuterAIModule, } = (await import('@heyputer/backend')).default; @@ -95,6 +96,7 @@ const main = async () => { k.add_module(new DatabaseModule()); k.add_module(new LocalDiskStorageModule()); k.add_module(new SelfHostedModule()); + k.add_module(new BroadcastModule()); k.add_module(new TestDriversModule()); // k.add_module(new PuterAIModule()); k.boot();