-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-server.js
More file actions
61 lines (54 loc) · 1.86 KB
/
Copy pathsimple-server.js
File metadata and controls
61 lines (54 loc) · 1.86 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
const http = require('http');
const url = require('url');
const PORT = process.env.PORT || 4000;
const server = http.createServer((req, res) => {
const parsedUrl = url.parse(req.url, true);
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.setHeader('Content-Type', 'application/json');
if (req.method === 'OPTIONS') {
res.writeHead(200);
res.end();
return;
}
if (parsedUrl.pathname === '/health') {
res.writeHead(200);
res.end(JSON.stringify({
status: 'ok',
message: 'Antagents DB Tool backend is running',
timestamp: new Date().toISOString()
}));
} else if (parsedUrl.pathname === '/api/v1/status') {
res.writeHead(200);
res.end(JSON.stringify({
project: 'Antagents DB Tool',
version: '0.1.0',
environment: process.env.NODE_ENV || 'development',
database: {
connected: false,
url: process.env.DATABASE_URL ? 'Configured' : 'Not configured'
},
redis: {
connected: false,
url: process.env.REDIS_URL ? 'Configured' : 'Not configured'
}
}));
} else {
res.writeHead(404);
res.end(JSON.stringify({ error: 'Not Found' }));
}
});
server.listen(PORT, () => {
console.log(`
🚀 Antagents DB Tool Backend Server (Simple)
=============================================
Server is running on http://localhost:${PORT}
Health check: http://localhost:${PORT}/health
API Status: http://localhost:${PORT}/api/v1/status
Environment: ${process.env.NODE_ENV || 'development'}
Database: ${process.env.DATABASE_URL ? '✅ Configured' : '❌ Not configured'}
Redis: ${process.env.REDIS_URL ? '✅ Configured' : '❌ Not configured'}
`);
});