Migrate to PostgreSQL and add DragonflyDB support

This commit is contained in:
VPS 4 Builder
2026-05-26 03:50:14 +02:00
parent bda5adf070
commit 13175f93aa
5 changed files with 197 additions and 369 deletions
+16
View File
@@ -18,6 +18,7 @@ const patientsRouter = require('./routes/patients');
const gtosRouter = require('./routes/gtos');
const systemRoutes = require('./routes/system');
const { checkInstallation } = require('./installer/check-installation');
const redis = require('./redis');
// ================================================================
// CONFIGURAÇÃO DO SERVIDOR
@@ -72,6 +73,18 @@ app.get('/status', (req, res) => {
});
});
// DragonflyDB Ping check
app.get('/api/redis/ping', async (req, res) => {
try {
const client = redis.getClient();
await client.set('ping_test', 'pong', 'EX', 10);
const value = await client.get('ping_test');
res.json({ success: true, dragonfly_db: 'connected', test_value: value });
} catch (error) {
res.status(500).json({ success: false, error: error.message });
}
});
// Verificar se o nome do computador/cliente já existe
app.get('/api/clients/check-name', async (req, res) => {
try {
@@ -911,6 +924,9 @@ async function start() {
console.log('⚠️ Banco de dados não configurado. Execute a instalação em /install');
}
// Inicializar cliente DragonflyDB/Redis
redis.initRedis();
// Iniciar servidor
server.listen(PORT, () => {
console.log('═══════════════════════════════════════════════════════');