docs: note TypeScript migration

This commit is contained in:
josedario87
2025-06-04 21:30:07 -06:00
parent dec4922d42
commit 0836c086b2
12 changed files with 545 additions and 30 deletions

27
chat-ui/src/server.ts Normal file
View File

@@ -0,0 +1,27 @@
import express, { Request, Response } from 'express';
import axios from 'axios';
import bodyParser from 'body-parser';
import path from 'path';
const app = express();
const port = Number(process.env.PORT) || 3000;
const agentUrl = process.env.LLM_AGENT_URL as string | undefined;
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, 'public')));
app.post('/send', async (req: Request, res: Response) => {
if (!agentUrl) {
return res.status(500).json({ error: 'LLM_AGENT_URL not configured' });
}
try {
const { message } = req.body;
const response = await axios.post(agentUrl, { message });
res.json(response.data);
} catch (err: any) {
console.error('Failed to forward message', err.message);
res.status(500).json({ error: 'Failed to communicate with agent' });
}
});
app.listen(port, () => console.log(`Chat UI listening on port ${port}`));