mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: serve plugin http and websockets from one mount instead of ports
This commit is contained in:
1 parent
c496a093ca
commit
8431570ff7
102 files changed
+2894
-2308
No files matched your search
@@ -2,8 +2,8 @@ import type { PluginContext } from "@termix/plugin-sdk/backend";
|
||||
import { startTailscaleService, stopTailscaleService } from "./routes.js";
|
||||
|
||||
export async function activate(ctx: PluginContext) {
|
||||
startTailscaleService();
|
||||
ctx.log.info("Tailscale router registered at /tailscale");
|
||||
startTailscaleService(ctx.http.router());
|
||||
ctx.log.info("Tailscale routes mounted at /plugin-api/tailscale");
|
||||
}
|
||||
|
||||
export async function deactivate() {
|
||||
|
||||
@@ -9,10 +9,6 @@ import { PermissionManager } from "../../../../src/backend/utils/permission-mana
|
||||
import { apiLogger } from "../../../../src/backend/utils/logger.js";
|
||||
import { fetchWithProxy } from "../../../../src/backend/utils/proxy-agent.js";
|
||||
import { createCurrentSettingsRepository } from "../../../../src/backend/database/repositories/factory.js";
|
||||
import {
|
||||
registerTailscaleRouter,
|
||||
unregisterTailscaleRouter,
|
||||
} from "../../../../src/backend/database/routes/tailscale-dispatch.js";
|
||||
|
||||
interface TailscaleDevice {
|
||||
id: string;
|
||||
@@ -152,12 +148,12 @@ router.get(
|
||||
|
||||
/** Called from activate(). Mounts this router at /tailscale via the shared
|
||||
* dispatcher. */
|
||||
export function startTailscaleService(): void {
|
||||
registerTailscaleRouter(router);
|
||||
export function startTailscaleService(mountOn: Router): void {
|
||||
mountOn.use(router);
|
||||
}
|
||||
|
||||
/** Called from deactivate(). /tailscale/* falls back to 404 until
|
||||
* reactivated. */
|
||||
export function stopTailscaleService(): void {
|
||||
unregisterTailscaleRouter();
|
||||
// Unmounted by the runtime when the plugin deactivates.
|
||||
}
|
||||
Reference in new issue
Block a user