Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
64 lines (55 loc) · 2.41 KB
/
Copy pathserver.js
File metadata and controls
64 lines (55 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const path = require('path');
const config = require('./config');
const apiRoutes = require('./routes/api');
const chatbotRoutes = require('./routes/chatbot');
const app = express();
// Middleware
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Serve static files from public directory
app.use(express.static(path.join(__dirname, 'public')));
// API routes
app.use('/api', apiRoutes);
app.use('/api', chatbotRoutes);
// Root route
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Error handling middleware
app.use((error, req, res, next) => {
console.error('Server error:', error);
res.status(500).json({
success: false,
error: error.message || 'Internal server error'
});
});
// Start server
const PORT = config.server.port;
app.listen(PORT, () => {
console.log(`
╔════════════════════════════════════════════════════════════╗
║ ║
║ 🎓 Multi-Agent Educational Transformation System ║
║ ║
║ Server running on: http://localhost:${PORT} ║
║ Environment: ${config.server.env} ║
║ ║
║ Four Agents Ready: ║
║ ✓ Agent 1: Document Analyzer ║
║ ✓ Agent 2: Simplification Specialist ║
║ ✓ Agent 3: Visual Synthesizer ║
║ ✓ Agent 4: Deep-Dive Expander ║
║ ║
╚════════════════════════════════════════════════════════════╝
`);
// Validate Groq API key
if (!config.groq.apiKey || config.groq.apiKey.includes('your_')) {
console.warn('\n⚠️ WARNING: GROQ_API_KEY not configured!');
console.warn('Please set your Groq API key in the .env file\n');
}
});
module.exports = app;