mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-09-13 10:49:21 +00:00
♻️ refactor: remove stale code and comments
This commit is contained in:
@@ -7,14 +7,12 @@ import { ReverseProxyService } from "./services/reverse-proxy.service";
|
||||
import { ServerService } from "./services/server.service";
|
||||
import { UserService } from "./services/user.service";
|
||||
|
||||
// Infrastructure layer
|
||||
const userRepo = new PrismaUserRepository();
|
||||
const serverRepo = new PrismaServerRepository();
|
||||
const reverseProxyRepo = new PrismaReverseProxyRepository();
|
||||
const webSocketService = new WebSocketService();
|
||||
const k8sService = new K8sService();
|
||||
|
||||
// Application layer
|
||||
export const userService = new UserService(userRepo);
|
||||
export const serverService = new ServerService(serverRepo, k8sService);
|
||||
export const reverseProxyService = new ReverseProxyService(reverseProxyRepo);
|
||||
|
||||
@@ -2,7 +2,6 @@ import type * as k8s from "@kubernetes/client-node";
|
||||
import type { CustomResourceSummary } from "@minikura/api";
|
||||
|
||||
export interface IK8sService {
|
||||
// Initialization
|
||||
isInitialized(): boolean;
|
||||
getConnectionInfo(): {
|
||||
initialized: boolean;
|
||||
@@ -11,7 +10,6 @@ export interface IK8sService {
|
||||
namespace: string;
|
||||
};
|
||||
|
||||
// Pods
|
||||
getPods(): Promise<any[]>;
|
||||
getPodsByLabel(labelSelector: string): Promise<any[]>;
|
||||
getPodInfo(podName: string): Promise<any>;
|
||||
@@ -26,20 +24,16 @@ export interface IK8sService {
|
||||
): Promise<string>;
|
||||
getPodMetrics(namespace?: string): Promise<any>;
|
||||
|
||||
// Workloads
|
||||
getDeployments(): Promise<any[]>;
|
||||
getStatefulSets(): Promise<any[]>;
|
||||
|
||||
// Network
|
||||
getServices(): Promise<any[]>;
|
||||
getIngresses(): Promise<any[]>;
|
||||
getServiceInfo(serviceName: string): Promise<any>;
|
||||
getServerConnectionInfo(serviceName: string): Promise<any>;
|
||||
|
||||
// Configuration
|
||||
getConfigMaps(): Promise<any[]>;
|
||||
|
||||
// Custom Resources
|
||||
getCustomResources(
|
||||
group: string,
|
||||
version: string,
|
||||
@@ -48,11 +42,9 @@ export interface IK8sService {
|
||||
getMinecraftServers(): Promise<CustomResourceSummary[]>;
|
||||
getReverseProxyServers(): Promise<CustomResourceSummary[]>;
|
||||
|
||||
// Cluster
|
||||
getNodes(): Promise<any[]>;
|
||||
getNodeMetrics(): Promise<any>;
|
||||
|
||||
// Low-level access
|
||||
getKubeConfig(): k8s.KubeConfig;
|
||||
getCoreApi(): k8s.CoreV1Api;
|
||||
getNamespace(): string;
|
||||
|
||||
@@ -8,13 +8,13 @@ export const DEFAULT_PORTS = {
|
||||
} as const;
|
||||
|
||||
export const DEFAULT_MEMORY = {
|
||||
SERVER: 2048, // MB
|
||||
REVERSE_PROXY: 512, // MB
|
||||
SERVER: 2048,
|
||||
REVERSE_PROXY: 512,
|
||||
} as const;
|
||||
|
||||
export const DEFAULT_MEMORY_REQUEST = {
|
||||
SERVER: 1024, // MB
|
||||
REVERSE_PROXY: 512, // MB
|
||||
SERVER: 1024,
|
||||
REVERSE_PROXY: 512,
|
||||
} as const;
|
||||
|
||||
export const DEFAULT_CPU = {
|
||||
|
||||
@@ -2,8 +2,8 @@ import { dotenvLoad } from "dotenv-mono";
|
||||
|
||||
dotenvLoad();
|
||||
|
||||
import { Elysia } from "elysia";
|
||||
import { node } from "@elysiajs/node";
|
||||
import { Elysia } from "elysia";
|
||||
import { logger } from "./infrastructure/logger";
|
||||
import { auth } from "./middleware/auth";
|
||||
import { authPlugin } from "./middleware/auth-plugin";
|
||||
@@ -15,7 +15,6 @@ import { serverRoutes } from "./routes/servers";
|
||||
import { terminalRoutes } from "./routes/terminal";
|
||||
import { userRoutes } from "./routes/users";
|
||||
|
||||
// Register event handlers
|
||||
import "./infrastructure/event-handlers";
|
||||
|
||||
const app = new Elysia({ adapter: node() })
|
||||
@@ -33,8 +32,7 @@ const app = new Elysia({ adapter: node() })
|
||||
.use(authPlugin)
|
||||
.group("/api", (app) =>
|
||||
app.use(userRoutes).use(serverRoutes).use(reverseProxyRoutes).use(k8sRoutes).use(terminalRoutes)
|
||||
)
|
||||
.get("/health", () => ({ status: "ok" }));
|
||||
);
|
||||
|
||||
export type App = typeof app;
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ export class PrismaReverseProxyRepository implements ReverseProxyRepository {
|
||||
throw new NotFoundError("ReverseProxyServer", id);
|
||||
}
|
||||
|
||||
// Update proxy fields
|
||||
const updated = await prisma.reverseProxyServer.update({
|
||||
where: { id },
|
||||
data: {
|
||||
|
||||
@@ -107,12 +107,10 @@ export class PrismaServerRepository implements ServerRepository {
|
||||
throw new NotFoundError("Server", id);
|
||||
}
|
||||
|
||||
// Handle env variables separately
|
||||
if (input.env_variables !== undefined) {
|
||||
await this.replaceEnvVariables(id, input.env_variables);
|
||||
}
|
||||
|
||||
// Update server fields
|
||||
const updated = await prisma.server.update({
|
||||
where: { id },
|
||||
data: {
|
||||
|
||||
@@ -46,7 +46,6 @@ export const k8sRoutes = new Elysia({ prefix: "/k8s" })
|
||||
};
|
||||
const logs = await k8sService.getPodLogs(params.podName, options);
|
||||
|
||||
// Return as plain text
|
||||
const headers = (set.headers ?? {}) as Record<string, string>;
|
||||
headers["content-type"] = "text/plain";
|
||||
set.headers = headers;
|
||||
|
||||
@@ -6,9 +6,7 @@ import type { IK8sService } from "../application/interfaces/k8s.service.interfac
|
||||
import { logger } from "../infrastructure/logger";
|
||||
import { ClusterOperations } from "./kubernetes/operations/cluster.operations";
|
||||
import { CustomResourceOperations } from "./kubernetes/operations/custom-resource.operations";
|
||||
import { NetworkOperations } from "./kubernetes/operations/network.operations";
|
||||
import { PodOperations } from "./kubernetes/operations/pod.operations";
|
||||
import { WorkloadOperations } from "./kubernetes/operations/workload.operations";
|
||||
import { K8sResources } from "./kubernetes/resources";
|
||||
|
||||
const CUSTOM_RESOURCE_VERSION = "v1alpha1";
|
||||
@@ -56,8 +54,6 @@ export class K8sService implements IK8sService {
|
||||
|
||||
private initializeOperations(): void {
|
||||
this.podOps = new PodOperations(this.coreApi, this.namespace);
|
||||
this.workloadOps = new WorkloadOperations(this.appsApi, this.namespace);
|
||||
this.networkOps = new NetworkOperations(this.coreApi, this.networkingApi, this.namespace);
|
||||
this.clusterOps = new ClusterOperations(this.coreApi, this.customObjectsApi, this.namespace);
|
||||
this.customResourceOps = new CustomResourceOperations(this.customObjectsApi, this.namespace);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ export class WebSocketService implements IWebSocketService {
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
|
||||
// Send to all connected clients, removing any that fail
|
||||
let failedClients = 0;
|
||||
this.clients.forEach((client) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user