72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
const express = require('express');
|
|
const cors = require('cors');
|
|
|
|
const app = express();
|
|
const port = 3001;
|
|
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
|
|
// Mock data for different types
|
|
const mockData = {
|
|
tasks: [
|
|
{ id: 1, title: 'Fix hydration issue', status: 'in_progress', priority: 'high' },
|
|
{ id: 2, title: 'Deploy to production', status: 'pending', priority: 'medium' },
|
|
{ id: 3, title: 'Update documentation', status: 'completed', priority: 'low' }
|
|
],
|
|
crons: [
|
|
{ id: 1, name: 'Daily backup', schedule: '0 2 * * *', lastRun: '2024-02-19T02:00:00Z', nextRun: '2024-02-20T02:00:00Z' },
|
|
{ id: 2, name: 'Health check', schedule: '*/5 * * * *', lastRun: '2024-02-19T13:15:00Z', nextRun: '2024-02-19T13:20:00Z' }
|
|
],
|
|
server: {
|
|
hostname: 'mission-control-server',
|
|
uptime: '52 days',
|
|
memory: { total: '62GB', used: '42GB', free: '20GB' },
|
|
disk: { total: '436GB', used: '128GB', free: '308GB' },
|
|
cpu: { usage: '24%', cores: 8 }
|
|
},
|
|
backups: [
|
|
{ id: 1, name: 'Full system backup', date: '2024-02-18', size: '45GB', status: 'success' },
|
|
{ id: 2, name: 'Database backup', date: '2024-02-19', size: '2.3GB', status: 'success' }
|
|
],
|
|
agents: [
|
|
{ id: 1, name: 'Jelena', status: 'active', role: 'main', lastSeen: '2024-02-19T13:10:00Z' },
|
|
{ id: 2, name: 'Linus', status: 'active', role: 'cto', lastSeen: '2024-02-19T13:05:00Z' },
|
|
{ id: 3, name: 'Neo', status: 'active', role: 'operator', lastSeen: '2024-02-19T13:15:00Z' }
|
|
],
|
|
whatsapp: {
|
|
connected: true,
|
|
lastMessage: '2024-02-19T13:05:00Z',
|
|
unread: 3,
|
|
groups: ['Team', 'Alerts', 'Support']
|
|
},
|
|
memory: {
|
|
dailyNotes: 24,
|
|
longTermEntries: 156,
|
|
lastUpdated: '2024-02-19T12:30:00Z'
|
|
}
|
|
};
|
|
|
|
// API endpoint
|
|
app.get('/api/data', (req, res) => {
|
|
const type = req.query.type;
|
|
|
|
if (!type) {
|
|
return res.status(400).json({ error: 'Missing type parameter' });
|
|
}
|
|
|
|
if (mockData[type]) {
|
|
return res.json(mockData[type]);
|
|
}
|
|
|
|
return res.status(404).json({ error: `Unknown type: ${type}` });
|
|
});
|
|
|
|
// Health check
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
|
});
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Simple API server running on port ${port}`);
|
|
}); |