feat: serve plugin http and websockets from one mount instead of ports

This commit is contained in:
LukeGus committed 2026-09-22 16:39:41 -05:00
1 parent c496a093ca
commit 8431570ff7
102 files changed
+2894 -2308

No files matched your search

+2 -2
View File
@@ -2,8 +2,8 @@ import type { PluginContext } from "@termix/plugin-sdk/backend";
import { startFleetsService, stopFleetsService } from "./routes.js";
export async function activate(ctx: PluginContext) {
startFleetsService();
ctx.log.info("Fleets router registered at /fleets");
startFleetsService(ctx.http.router());
ctx.log.info("Fleets routes mounted at /plugin-api/fleets");
}
export async function deactivate() {
+4 -8
View File
@@ -1,6 +1,6 @@
import { getErrorMessage } from "../../../../src/backend/utils/error-message.js";
import type { AuthenticatedRequest } from "../../../../src/types/index.js";
import express, { type Request, type Response } from "express";
import express, { type Request, type Response, type Router } from "express";
import multer from "multer";
import JSZip from "jszip";
import type { Client, SFTPWrapper } from "ssh2";
@@ -40,10 +40,6 @@ import {
import { buildPackageActionCommand } from "../../../../src/backend/hosts/metrics-shared/package-commands.js";
import { isValidPackageName } from "../../../../src/backend/hosts/metrics-shared/validation.js";
import { resolveSnippetCommand } from "../../../../src/backend/database/routes/snippets-execution.js";
import {
registerFleetsRouter,
unregisterFleetsRouter,
} from "../../../../src/backend/database/routes/fleet-dispatch.js";
export const router = express.Router();
@@ -1505,11 +1501,11 @@ export function buildRemoveCommand(
/** Called from activate(). Mounts this router at /fleets via the shared
* dispatcher. */
export function startFleetsService(): void {
registerFleetsRouter(router);
export function startFleetsService(mountOn: Router): void {
mountOn.use(router);
}
/** Called from deactivate(). /fleets/* falls back to 404 until reactivated. */
export function stopFleetsService(): void {
unregisterFleetsRouter();
// Unmounted by the runtime when the plugin deactivates.
}