From 5567ac6594767a0818d58576b8599a31f53563a5 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Thu, 13 Aug 2026 02:32:39 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20restore=20plugin=20auth?= =?UTF-8?q?=20and=20proxy=20connection=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/backend/src/application/di-container.ts | 6 +++- .../reverse-proxy.service.interface.ts | 1 + .../services/reverse-proxy.service.ts | 13 ++++++++- apps/backend/src/index.ts | 9 +++++- .../reverse-proxy-event.handler.ts | 6 ++-- .../event-handlers/server-event.handler.ts | 6 ++-- .../prisma/reverse-proxy.repository.impl.ts | 6 ++-- .../prisma/server.repository.impl.ts | 8 +++--- apps/backend/src/middleware/api-key.ts | 19 +++++++++++++ apps/backend/src/routes/plugin.ts | 8 ++++++ apps/backend/src/routes/reverse-proxy.ts | 16 ++++++----- apps/backend/src/routes/servers.ts | 20 +++++++------ apps/backend/src/routes/terminal.ts | 3 +- apps/backend/src/routes/users.ts | 28 +++++++++---------- apps/web/hooks/use-topology-data.ts | 17 ++++++++++- apps/web/lib/topology-utils.ts | 16 ++++++++--- apps/web/package.json | 1 + bun.lock | 6 ++++ .../cafe/kirameki/minikuraVelocity/Main.kt | 6 ++-- .../MinikuraWebSocketClient.kt | 11 ++------ 20 files changed, 141 insertions(+), 65 deletions(-) create mode 100644 apps/backend/src/middleware/api-key.ts create mode 100644 apps/backend/src/routes/plugin.ts diff --git a/apps/backend/src/application/di-container.ts b/apps/backend/src/application/di-container.ts index ca4a696..202d8f2 100644 --- a/apps/backend/src/application/di-container.ts +++ b/apps/backend/src/application/di-container.ts @@ -17,6 +17,10 @@ const operatorResourceSync = new OperatorResourceSync(); export const userService = new UserService(userRepo); export const serverService = new ServerService(serverRepo, k8sService, operatorResourceSync); -export const reverseProxyService = new ReverseProxyService(reverseProxyRepo, operatorResourceSync); +export const reverseProxyService = new ReverseProxyService( + reverseProxyRepo, + k8sService, + operatorResourceSync +); export const wsService = webSocketService; export { k8sService, operatorResourceSync }; diff --git a/apps/backend/src/application/interfaces/reverse-proxy.service.interface.ts b/apps/backend/src/application/interfaces/reverse-proxy.service.interface.ts index 087c96f..3c38db4 100644 --- a/apps/backend/src/application/interfaces/reverse-proxy.service.interface.ts +++ b/apps/backend/src/application/interfaces/reverse-proxy.service.interface.ts @@ -13,4 +13,5 @@ export interface IReverseProxyService { setEnvVariable(proxyId: string, key: string, value: string): Promise; getEnvVariables(proxyId: string): Promise; deleteEnvVariable(proxyId: string, key: string): Promise; + getConnectionInfo(proxyId: string): Promise; } diff --git a/apps/backend/src/application/services/reverse-proxy.service.ts b/apps/backend/src/application/services/reverse-proxy.service.ts index 8661c81..b5a8a7f 100644 --- a/apps/backend/src/application/services/reverse-proxy.service.ts +++ b/apps/backend/src/application/services/reverse-proxy.service.ts @@ -9,7 +9,11 @@ import type { ReverseProxyRepository, ReverseProxyUpdateInput, } from "../../domain/repositories/reverse-proxy.repository"; -import type { OperatorResourceSync } from "../../services/operator-resource-sync"; +import type { K8sService } from "../../services/k8s"; +import { + type OperatorResourceSync, + operatorResourceName, +} from "../../services/operator-resource-sync"; import type { IReverseProxyService } from "../interfaces/reverse-proxy.service.interface"; import { BaseCrudService } from "./base-crud.service"; @@ -29,6 +33,7 @@ export class ReverseProxyService { constructor( reverseProxyRepo: ReverseProxyRepository, + private k8sService: K8sService, private operatorResourceSync: OperatorResourceSync ) { super( @@ -79,4 +84,10 @@ export class ReverseProxyService await super.deleteEnvVariable(proxyId, key); await this.operatorResourceSync.syncReverseProxyById(proxyId); } + + async getConnectionInfo(proxyId: string) { + const proxy = await this.getReverseProxyById(proxyId); + const serviceName = `${String(proxy.type).toLowerCase()}-${operatorResourceName(proxyId)}`; + return this.k8sService.getServerConnectionInfo(serviceName); + } } diff --git a/apps/backend/src/index.ts b/apps/backend/src/index.ts index 1120804..45767a1 100644 --- a/apps/backend/src/index.ts +++ b/apps/backend/src/index.ts @@ -10,6 +10,7 @@ import { authPlugin } from "./middleware/auth-plugin"; import { errorHandler } from "./middleware/error-handler"; import { bootstrapRoutes } from "./routes/bootstrap"; import { k8sRoutes } from "./routes/k8s"; +import { pluginRoutes } from "./routes/plugin"; import { reverseProxyRoutes } from "./routes/reverse-proxy"; import { serverRoutes } from "./routes/servers"; import { terminalRoutes } from "./routes/terminal"; @@ -34,7 +35,13 @@ const app = new Elysia({ adapter: node() }) .use(bootstrapRoutes) .use(authPlugin) .group("/api", (app) => - app.use(userRoutes).use(serverRoutes).use(reverseProxyRoutes).use(k8sRoutes).use(terminalRoutes) + app + .use(userRoutes) + .use(serverRoutes) + .use(reverseProxyRoutes) + .use(pluginRoutes) + .use(k8sRoutes) + .use(terminalRoutes) ); export type App = typeof app; diff --git a/apps/backend/src/infrastructure/event-handlers/reverse-proxy-event.handler.ts b/apps/backend/src/infrastructure/event-handlers/reverse-proxy-event.handler.ts index b5edfba..1035e5c 100644 --- a/apps/backend/src/infrastructure/event-handlers/reverse-proxy-event.handler.ts +++ b/apps/backend/src/infrastructure/event-handlers/reverse-proxy-event.handler.ts @@ -12,18 +12,18 @@ eventBus.subscribe(ReverseProxyCreatedEvent, async (event) => { { proxyId: event.proxyId, proxyType: event.proxyType }, "Reverse proxy created event" ); - wsService.broadcast("create", event.proxyType, event.proxyId); + wsService.broadcast("CREATE", event.proxyType, event.proxyId); await operatorResourceSync.syncReverseProxyById(event.proxyId); }); eventBus.subscribe(ReverseProxyUpdatedEvent, async (event) => { logger.info({ proxyId: event.proxyId }, "Reverse proxy updated event"); - wsService.broadcast("update", "reverse-proxy", event.proxyId); + wsService.broadcast("UPDATE", "reverse-proxy", event.proxyId); await operatorResourceSync.syncReverseProxyById(event.proxyId); }); eventBus.subscribe(ReverseProxyDeletedEvent, async (event) => { logger.info({ proxyId: event.proxyId }, "Reverse proxy deleted event"); - wsService.broadcast("delete", "reverse-proxy", event.proxyId); + wsService.broadcast("DELETE", "reverse-proxy", event.proxyId); await operatorResourceSync.deleteReverseProxy(event.proxyId); }); diff --git a/apps/backend/src/infrastructure/event-handlers/server-event.handler.ts b/apps/backend/src/infrastructure/event-handlers/server-event.handler.ts index ff17f04..e2cf723 100644 --- a/apps/backend/src/infrastructure/event-handlers/server-event.handler.ts +++ b/apps/backend/src/infrastructure/event-handlers/server-event.handler.ts @@ -9,18 +9,18 @@ import { logger } from "../logger"; eventBus.subscribe(ServerCreatedEvent, async (event) => { logger.info({ serverId: event.serverId, serverType: event.serverType }, "Server created event"); - wsService.broadcast("create", event.serverType, event.serverId); + wsService.broadcast("CREATE", event.serverType, event.serverId); await operatorResourceSync.syncServerById(event.serverId); }); eventBus.subscribe(ServerUpdatedEvent, async (event) => { logger.info({ serverId: event.serverId }, "Server updated event"); - wsService.broadcast("update", "server", event.serverId); + wsService.broadcast("UPDATE", "server", event.serverId); await operatorResourceSync.syncServerById(event.serverId); }); eventBus.subscribe(ServerDeletedEvent, async (event) => { logger.info({ serverId: event.serverId }, "Server deleted event"); - wsService.broadcast("delete", "server", event.serverId); + wsService.broadcast("DELETE", "server", event.serverId); await operatorResourceSync.deleteServer(event.serverId); }); diff --git a/apps/backend/src/infrastructure/repositories/prisma/reverse-proxy.repository.impl.ts b/apps/backend/src/infrastructure/repositories/prisma/reverse-proxy.repository.impl.ts index 27c3d17..f1d4940 100644 --- a/apps/backend/src/infrastructure/repositories/prisma/reverse-proxy.repository.impl.ts +++ b/apps/backend/src/infrastructure/repositories/prisma/reverse-proxy.repository.impl.ts @@ -64,12 +64,12 @@ export class PrismaReverseProxyRepository implements ReverseProxyRepository { description: input.description ?? null, external_address: input.external_address, external_port: input.external_port, - listen_port: input.listen_port ?? 25577, + listen_port: input.listen_port ?? 25565, service_type: input.service_type ?? "LOAD_BALANCER", node_port: input.node_port ?? null, memory: input.memory ?? 512, - cpu_request: input.cpu_request ?? "100m", - cpu_limit: input.cpu_limit ?? "200m", + cpu_request: input.cpu_request ?? "250m", + cpu_limit: input.cpu_limit ?? "500m", api_key: token, env_variables: input.env_variables ? { diff --git a/apps/backend/src/infrastructure/repositories/prisma/server.repository.impl.ts b/apps/backend/src/infrastructure/repositories/prisma/server.repository.impl.ts index 402079c..7a401cb 100644 --- a/apps/backend/src/infrastructure/repositories/prisma/server.repository.impl.ts +++ b/apps/backend/src/infrastructure/repositories/prisma/server.repository.impl.ts @@ -67,12 +67,12 @@ export class PrismaServerRepository implements ServerRepository { node_port: input.node_port ?? null, memory: input.memory ?? 2048, memory_request: input.memory_request ?? 1024, - cpu_request: input.cpu_request ?? "250m", - cpu_limit: input.cpu_limit ?? "500m", - jar_type: input.jar_type ?? "PAPER", + cpu_request: input.cpu_request ?? "500m", + cpu_limit: input.cpu_limit ?? "2", + jar_type: input.jar_type ?? "VANILLA", minecraft_version: input.minecraft_version ?? "LATEST", jvm_opts: input.jvm_opts ?? null, - use_aikar_flags: input.use_aikar_flags ?? true, + use_aikar_flags: input.use_aikar_flags ?? false, use_meowice_flags: input.use_meowice_flags ?? false, difficulty: input.difficulty ?? "EASY", game_mode: input.game_mode ?? "SURVIVAL", diff --git a/apps/backend/src/middleware/api-key.ts b/apps/backend/src/middleware/api-key.ts new file mode 100644 index 0000000..6e9cf52 --- /dev/null +++ b/apps/backend/src/middleware/api-key.ts @@ -0,0 +1,19 @@ +import { prisma } from "@minikura/db"; + +export async function findApiKeyOwner(apiKey: string) { + if (!apiKey) return null; + + const [server, proxy] = await Promise.all([ + prisma.server.findUnique({ where: { api_key: apiKey }, select: { id: true } }), + prisma.reverseProxyServer.findUnique({ where: { api_key: apiKey }, select: { id: true } }), + ]); + + if (server) return { kind: "server" as const, id: server.id }; + if (proxy) return { kind: "reverse-proxy" as const, id: proxy.id }; + return null; +} + +export function bearerToken(header: string | null): string { + if (!header?.startsWith("Bearer ")) return ""; + return header.slice(7).trim(); +} diff --git a/apps/backend/src/routes/plugin.ts b/apps/backend/src/routes/plugin.ts new file mode 100644 index 0000000..046f713 --- /dev/null +++ b/apps/backend/src/routes/plugin.ts @@ -0,0 +1,8 @@ +import { Elysia } from "elysia"; +import { reverseProxyService, serverService } from "../application/di-container"; +import { requirePluginApiKey } from "../middleware/auth-guards"; + +export const pluginRoutes = new Elysia({ prefix: "/plugin" }) + .use(requirePluginApiKey) + .get("/servers", async () => serverService.getAllServers(true)) + .get("/reverse-proxy", async () => reverseProxyService.getAllReverseProxies(true)); diff --git a/apps/backend/src/routes/reverse-proxy.ts b/apps/backend/src/routes/reverse-proxy.ts index ff09ad5..93469a4 100644 --- a/apps/backend/src/routes/reverse-proxy.ts +++ b/apps/backend/src/routes/reverse-proxy.ts @@ -1,13 +1,11 @@ import { Elysia } from "elysia"; -import { z } from "zod"; import { reverseProxyService } from "../application/di-container"; import { requireAuth } from "../middleware/auth-guards"; -import { createReverseProxySchema, updateReverseProxySchema } from "../schemas/server.schema"; - -const envVariableSchema = z.object({ - key: z.string(), - value: z.string(), -}); +import { + createReverseProxySchema, + envVariableSchema, + updateReverseProxySchema, +} from "../schemas/server.schema"; export const reverseProxyRoutes = new Elysia({ prefix: "/reverse-proxy" }) .use(requireAuth) @@ -19,6 +17,10 @@ export const reverseProxyRoutes = new Elysia({ prefix: "/reverse-proxy" }) return await reverseProxyService.getReverseProxyById(params.id, false); }) + .get("/:id/connection-info", async ({ params }) => { + return await reverseProxyService.getConnectionInfo(params.id); + }) + .post("/", async ({ body }) => { const payload = createReverseProxySchema.parse(body); const proxy = await reverseProxyService.createReverseProxy(payload); diff --git a/apps/backend/src/routes/servers.ts b/apps/backend/src/routes/servers.ts index 654c54b..4926bdd 100644 --- a/apps/backend/src/routes/servers.ts +++ b/apps/backend/src/routes/servers.ts @@ -1,19 +1,21 @@ import { Elysia } from "elysia"; -import { z } from "zod"; import { serverService, wsService } from "../application/di-container"; +import { findApiKeyOwner } from "../middleware/api-key"; import { requireAuth } from "../middleware/auth-guards"; -import { createServerSchema, updateServerSchema } from "../schemas/server.schema"; +import { + createServerSchema, + envVariableSchema, + updateServerSchema, +} from "../schemas/server.schema"; import type { WebSocketClient } from "../services/websocket"; -const envVariableSchema = z.object({ - key: z.string(), - value: z.string(), -}); - export const serverRoutes = new Elysia({ prefix: "/servers" }) .ws("/ws", { - open(ws: WebSocketClient & { data?: { query?: Record }; close: () => void }) { - if (!ws.data?.query?.apiKey) { + async open( + ws: WebSocketClient & { data?: { query?: Record }; close: () => void } + ) { + const owner = await findApiKeyOwner(ws.data?.query?.apiKey ?? ""); + if (!owner) { ws.close(); return; } diff --git a/apps/backend/src/routes/terminal.ts b/apps/backend/src/routes/terminal.ts index 89656e0..5960638 100644 --- a/apps/backend/src/routes/terminal.ts +++ b/apps/backend/src/routes/terminal.ts @@ -2,6 +2,7 @@ import { getErrorMessage } from "@minikura/shared/errors"; import { Elysia } from "elysia"; import { k8sService } from "../application/di-container"; import { logger } from "../infrastructure/logger"; +import { requireAuth } from "../middleware/auth-guards"; type TerminalWsData = { query?: Record; @@ -25,7 +26,7 @@ type BunTlsOptions = { ca?: string; }; -export const terminalRoutes = new Elysia({ prefix: "/terminal" }).ws("/exec", { +export const terminalRoutes = new Elysia({ prefix: "/terminal" }).use(requireAuth).ws("/exec", { open: async (ws: TerminalWs) => { const podName = ws.data.query?.podName; const container = ws.data.query?.container; diff --git a/apps/backend/src/routes/users.ts b/apps/backend/src/routes/users.ts index f0338d0..e5b4251 100644 --- a/apps/backend/src/routes/users.ts +++ b/apps/backend/src/routes/users.ts @@ -1,29 +1,27 @@ -import type { UpdateUserInput } from "@minikura/db"; import { Elysia } from "elysia"; import { userService } from "../application/di-container"; -import { requireAdmin, requireAuth } from "../middleware/auth-guards"; +import { requireAdmin } from "../middleware/auth-guards"; +import { updateSuspensionSchema, updateUserSchema } from "../schemas/user.schema"; export const userRoutes = new Elysia({ prefix: "/users" }) .use(requireAdmin) .get("/", async () => { - const users = await userService.getAllUsers(); - return users; + return await userService.getAllUsers(); }) - - .use(requireAuth) .get("/:id", async ({ params }) => { - const foundUser = await userService.getUserById(params.id); - return foundUser; + return await userService.getUserById(params.id); }) - - .use(requireAdmin) .patch("/:id", async ({ params, body }) => { - const input = body as UpdateUserInput; - const updatedUser = await userService.updateUser(params.id, input); - return updatedUser; + const input = updateUserSchema.parse(body); + return await userService.updateUser(params.id, input); + }) + .patch("/:id/suspension", async ({ params, body }) => { + const payload = updateSuspensionSchema.parse(body); + return await userService.updateSuspension(params.id, { + isSuspended: payload.isSuspended, + suspendedUntil: payload.suspendedUntil ? new Date(payload.suspendedUntil) : null, + }); }) - - .use(requireAuth) .delete("/:id", async ({ params, user }) => { await userService.deleteUser(user.id, params.id); return { success: true }; diff --git a/apps/web/hooks/use-topology-data.ts b/apps/web/hooks/use-topology-data.ts index ac239ab..e8157d4 100644 --- a/apps/web/hooks/use-topology-data.ts +++ b/apps/web/hooks/use-topology-data.ts @@ -1,6 +1,6 @@ "use client"; -import type { ConnectionInfo, K8sNodeSummary, PodInfo } from "@minikura/api"; +import type { ConnectionInfo, CustomResourceSummary, K8sNodeSummary, PodInfo } from "@minikura/api"; import { useCallback, useEffect, useState } from "react"; import { api } from "@/lib/api-client"; import { getReverseProxyApi } from "@/lib/api-helpers"; @@ -119,6 +119,20 @@ export function useTopologyData() { nodeMetrics = nodeMetricsRes.data || { items: [] }; } catch (_err) {} + const proxyBackends = new Map(); + try { + const crResponse = await api.api.k8s["reverse-proxy-servers"].get(); + for (const cr of (crResponse.data as CustomResourceSummary[]) || []) { + const backends = cr.status?.backends; + if (cr.name && Array.isArray(backends)) { + proxyBackends.set( + cr.name, + backends.filter((id): id is string => typeof id === "string") + ); + } + } + } catch (_err) {} + const topologyGraph = buildTopologyGraph({ servers: normalServers, proxies: reverseProxies, @@ -127,6 +141,7 @@ export function useTopologyData() { k8sNodes, serverConnections: serverConnectionMap, proxyConnections: proxyConnectionMap, + proxyBackends, podMetrics, nodeMetrics, }); diff --git a/apps/web/lib/topology-utils.ts b/apps/web/lib/topology-utils.ts index 0cc427c..acaf65b 100644 --- a/apps/web/lib/topology-utils.ts +++ b/apps/web/lib/topology-utils.ts @@ -59,15 +59,22 @@ interface BuildEnhancedGraphInput { k8sNodes: K8sNodeSummary[]; serverConnections?: Map; proxyConnections?: Map; + proxyBackends?: Map; podMetrics?: any; nodeMetrics?: any; } function parseProxyServerConnections( - _proxy: ReverseProxyServer, - allServers: NormalServer[] + proxy: ReverseProxyServer, + allServers: NormalServer[], + backendsByProxyId?: Map ): string[] { - return allServers.map((s) => s.id); + const backends = backendsByProxyId?.get(proxy.id); + if (!backends) { + return allServers.map((s) => s.id); + } + const known = new Set(allServers.map((s) => s.id)); + return backends.filter((id) => known.has(id)); } export function buildTopologyGraph(input: BuildEnhancedGraphInput): TopologyGraph { @@ -79,6 +86,7 @@ export function buildTopologyGraph(input: BuildEnhancedGraphInput): TopologyGrap k8sNodes, serverConnections, proxyConnections, + proxyBackends, podMetrics, nodeMetrics, } = input; @@ -103,7 +111,7 @@ export function buildTopologyGraph(input: BuildEnhancedGraphInput): TopologyGrap } for (const proxy of proxies) { - const connectedServerIds = parseProxyServerConnections(proxy, servers); + const connectedServerIds = parseProxyServerConnections(proxy, servers, proxyBackends); proxyToServers.set(proxy.id, connectedServerIds); for (const serverId of connectedServerIds) { diff --git a/apps/web/package.json b/apps/web/package.json index 7c5dada..ebb83c3 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -23,6 +23,7 @@ "@hookform/resolvers": "^5.7.1", "@minikura/api": "workspace:*", "@minikura/backend": "workspace:*", + "@minikura/shared": "workspace:*", "@radix-ui/react-accordion": "^1.2.20", "@radix-ui/react-avatar": "^1.2.6", "@radix-ui/react-checkbox": "^1.3.11", diff --git a/bun.lock b/bun.lock index ccd0483..0324ba5 100644 --- a/bun.lock +++ b/bun.lock @@ -49,6 +49,7 @@ "@hookform/resolvers": "^5.7.1", "@minikura/api": "workspace:*", "@minikura/backend": "workspace:*", + "@minikura/shared": "workspace:*", "@radix-ui/react-accordion": "^1.2.20", "@radix-ui/react-avatar": "^1.2.6", "@radix-ui/react-checkbox": "^1.3.11", @@ -97,6 +98,9 @@ "typescript": "^7.0.2", }, }, + "operator": { + "name": "@minikura/operator", + }, "packages/api": { "name": "@minikura/api", "dependencies": { @@ -333,6 +337,8 @@ "@minikura/db": ["@minikura/db@workspace:packages/db"], + "@minikura/operator": ["@minikura/operator@workspace:operator"], + "@minikura/shared": ["@minikura/shared@workspace:packages/shared"], "@minikura/web": ["@minikura/web@workspace:apps/web"], diff --git a/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/Main.kt b/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/Main.kt index d094484..b0d9440 100644 --- a/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/Main.kt +++ b/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/Main.kt @@ -42,7 +42,7 @@ class Main @Inject constructor(private val logger: Logger, private val server: P private val client = OkHttpClient() private val apiKey: String = System.getenv("MINIKURA_API_KEY") ?: "" private val apiUrl: String = System.getenv("MINIKURA_API_URL") ?: "http://localhost:3000/api" - private val websocketUrl: String = System.getenv("MINIKURA_WEBSOCKET_URL") ?: "ws://localhost:3000/ws?apiKey=$apiKey" + private val websocketUrl: String = System.getenv("MINIKURA_WEBSOCKET_URL") ?: "ws://localhost:3000/api/servers/ws?apiKey=$apiKey" private var acceptingTransfers = AtomicBoolean(false) private val redisBungeeApi = RedisBungeeAPI.getRedisBungeeApi() @@ -158,7 +158,7 @@ class Main @Inject constructor(private val logger: Logger, private val server: P private fun fetchReverseProxyServers() { val request = Request.Builder() - .url("$apiUrl/reverse_proxy_servers") + .url("$apiUrl/plugin/reverse-proxy") .header("Authorization", "Bearer $apiKey") .build() @@ -185,7 +185,7 @@ class Main @Inject constructor(private val logger: Logger, private val server: P private fun fetchServers() { server.allServers.forEach { server.unregisterServer(it.serverInfo) } val request = Request.Builder() - .url("$apiUrl/servers") + .url("$apiUrl/plugin/servers") .header("Authorization", "Bearer $apiKey") .build() diff --git a/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/MinikuraWebSocketClient.kt b/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/MinikuraWebSocketClient.kt index 5c73af2..296c307 100644 --- a/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/MinikuraWebSocketClient.kt +++ b/plugins/MinikuraVelocity/src/main/kotlin/cafe/kirameki/minikuraVelocity/MinikuraWebSocketClient.kt @@ -30,14 +30,7 @@ class MinikuraWebSocketClient(private val plugin: Main, private val logger: Logg "test" -> { logger.info("API Call detected: endpoint=$endpoint, timestamp=$timestamp") - when (endpoint) { - "/servers" -> { - logger.info("dawdawdawdawd") - } - else -> { - logger.info("API endpoint $endpoint was accessed") - } - } + logger.info("API endpoint $endpoint was accessed") } "SERVER_CHANGE" -> { val action = jsonObject.get("action")?.asString @@ -46,7 +39,7 @@ class MinikuraWebSocketClient(private val plugin: Main, private val logger: Logg logger.info("Server change detected: action=$action, serverType=$serverType, serverId=$serverId") - when (action) { + when (action?.uppercase()) { "CREATE" -> { logger.info("Server '$serverId' was created") executeRefreshCommand()