feat: retro Claude ekip konsolunu kur
This commit is contained in:
51
server/index.js
Normal file
51
server/index.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import express from "express";
|
||||
import http from "http";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { Server } from "socket.io";
|
||||
import { getPublicRuntimeConfig, getRuntimeConfig } from "./config.js";
|
||||
import { SessionManager } from "./sessionManager.js";
|
||||
import { registerSocketHandlers } from "./socketHandlers.js";
|
||||
|
||||
const config = getRuntimeConfig();
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
const io = new Server(server, {
|
||||
cors: {
|
||||
origin: "*"
|
||||
}
|
||||
});
|
||||
|
||||
const sessionManager = new SessionManager({ io, config });
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const webDistPath = path.resolve(__dirname, "../web/dist");
|
||||
|
||||
app.get("/health", (req, res) => {
|
||||
res.json({
|
||||
ok: true,
|
||||
runtime: getPublicRuntimeConfig(config),
|
||||
session: sessionManager.getState()
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/api/session/state", (req, res) => {
|
||||
res.json({
|
||||
state: sessionManager.getState(),
|
||||
logs: sessionManager.getLogSnapshot(),
|
||||
chat: sessionManager.getChatSnapshot()
|
||||
});
|
||||
});
|
||||
|
||||
if (config.nodeEnv === "production") {
|
||||
app.use(express.static(webDistPath));
|
||||
app.get("*", (req, res) => {
|
||||
res.sendFile(path.join(webDistPath, "index.html"));
|
||||
});
|
||||
}
|
||||
|
||||
registerSocketHandlers(io, sessionManager);
|
||||
|
||||
server.listen(config.port, () => {
|
||||
console.log(`Retro console server listening on http://localhost:${config.port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user