feat: add Docker and Gitea services, monitoring, queue, and Telegram notification functionalities
- Implemented Docker operations including image building, container management, and resource stats. - Added Gitea API client for repository management and webhook handling. - Introduced monitoring service to collect and store container metrics in InfluxDB. - Created a queue system using BullMQ for managing deployment jobs with real-time log streaming. - Developed Telegram notification service for deployment status updates. - Added Traefik label generation for dynamic reverse proxy configuration. - Implemented WebSocket endpoints for log streaming and terminal access to containers. - Created an updater sidecar for self-updating the AutoDeployer container.
This commit is contained in:
77
server/src/routes/settings.js
Normal file
77
server/src/routes/settings.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import { Router } from 'express';
|
||||
import * as db from '../db/index.js';
|
||||
import { testConnection as testGitea } from '../services/gitea.js';
|
||||
import { testTelegram } from '../services/telegram.js';
|
||||
import { getQueueStatus } from '../services/queue.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
/**
|
||||
* GET /api/settings — Get all settings
|
||||
*/
|
||||
router.get('/', (_req, res) => {
|
||||
try {
|
||||
const settings = db.getAllSettings();
|
||||
res.json(settings);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* PUT /api/settings — Bulk update settings
|
||||
*/
|
||||
router.put('/', (req, res) => {
|
||||
try {
|
||||
const { settings } = req.body;
|
||||
if (!settings || typeof settings !== 'object') {
|
||||
return res.status(400).json({ error: 'settings object required' });
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(settings)) {
|
||||
db.setSetting(key, String(value));
|
||||
}
|
||||
|
||||
res.json({ ok: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /api/settings/test/gitea — Test Gitea connection
|
||||
*/
|
||||
router.get('/test/gitea', async (_req, res) => {
|
||||
try {
|
||||
const result = await testGitea();
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
res.json({ ok: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /api/settings/test/telegram — Test Telegram bot
|
||||
*/
|
||||
router.get('/test/telegram', async (_req, res) => {
|
||||
try {
|
||||
const result = await testTelegram();
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
res.json({ ok: false, error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /api/settings/queue — Get build queue status
|
||||
*/
|
||||
router.get('/queue', async (_req, res) => {
|
||||
try {
|
||||
const status = await getQueueStatus();
|
||||
res.json(status);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user