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
@@ -3,7 +3,7 @@ import { startAiService, stopAiService } from "./routes.js";
|
||||
import { createCurrentAiRepository } from "../../../../src/backend/database/repositories/factory.js";
|
||||
|
||||
export async function activate(ctx: PluginContext) {
|
||||
startAiService();
|
||||
startAiService(ctx.http.router());
|
||||
|
||||
// Offered by reference, not copied: this hands over a resolver, so the key
|
||||
// stays ours. Rotating or deleting the provider takes effect on the next
|
||||
@@ -24,7 +24,7 @@ export async function activate(ctx: PluginContext) {
|
||||
return withSecret?.apiKey ?? null;
|
||||
});
|
||||
|
||||
ctx.log.info("AI assistant router registered at /ai");
|
||||
ctx.log.info("AI assistant routes mounted at /plugin-api/ai");
|
||||
}
|
||||
|
||||
export async function deactivate() {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { getErrorMessage } from "../../../../src/backend/utils/error-message.js";
|
||||
import express from "express";
|
||||
import {
|
||||
registerAiRouter,
|
||||
unregisterAiRouter,
|
||||
} from "../../../../src/backend/database/routes/ai-dispatch.js";
|
||||
import express, { type Router } from "express";
|
||||
import type { AuthenticatedRequest } from "../../../../src/types/index.js";
|
||||
import { PermissionManager } from "../../../../src/backend/utils/permission-manager.js";
|
||||
import { AuthManager } from "../../../../src/backend/utils/auth-manager.js";
|
||||
@@ -1339,12 +1335,12 @@ router.post(
|
||||
},
|
||||
);
|
||||
|
||||
/** Called from activate(). Mounts this router at /ai via the shared dispatcher. */
|
||||
export function startAiService(): void {
|
||||
registerAiRouter(router);
|
||||
/** Called from activate(). Mounts this router at /plugin-api/ai. */
|
||||
export function startAiService(mountOn: Router): void {
|
||||
mountOn.use(router);
|
||||
}
|
||||
|
||||
/** Called from deactivate(). /ai/* falls back to 404 until reactivated. */
|
||||
export function stopAiService(): void {
|
||||
unregisterAiRouter();
|
||||
// Unmounted by the runtime when the plugin deactivates.
|
||||
}
|
||||
Reference in new issue
Block a user