MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / configureServer

Function configureServer

apps/webuiapps/vite.config.ts:24–68  ·  view source on GitHub ↗
(server)

Source from the content-addressed store, hash-verified

22 return {
23 name: 'llm-config',
24 configureServer(server) {
25 server.middlewares.use('/api/llm-config', (req, res) => {
26 res.setHeader('Content-Type', 'application/json');
27
28 if (req.method === 'GET') {
29 try {
30 if (fs.existsSync(LLM_CONFIG_FILE)) {
31 const content = fs.readFileSync(LLM_CONFIG_FILE, 'utf-8');
32 res.writeHead(200);
33 res.end(content);
34 } else {
35 res.writeHead(200);
36 res.end('{}');
37 }
38 } catch (err) {
39 res.writeHead(500);
40 res.end(JSON.stringify({ error: String(err) }));
41 }
42 return;
43 }
44
45 if (req.method === 'POST') {
46 const chunks: Buffer[] = [];
47 req.on('data', (chunk: Buffer) => chunks.push(chunk));
48 req.on('end', () => {
49 try {
50 const body = Buffer.concat(chunks).toString();
51 // Validate JSON before writing
52 JSON.parse(body);
53 fs.mkdirSync(resolve(os.homedir(), '.openroom'), { recursive: true });
54 fs.writeFileSync(LLM_CONFIG_FILE, body, 'utf-8');
55 res.writeHead(200);
56 res.end(JSON.stringify({ ok: true }));
57 } catch (err) {
58 res.writeHead(500);
59 res.end(JSON.stringify({ error: String(err) }));
60 }
61 });
62 return;
63 }
64
65 res.writeHead(405);
66 res.end(JSON.stringify({ error: 'Method not allowed' }));
67 });
68 },
69 };
70}
71

Callers

nothing calls this directly

Calls 6

generateLogFileNameFunction · 0.90
createLogMiddlewareFunction · 0.90
pumpFunction · 0.85
logMethod · 0.80
onMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected