UI: Add git commit hash and age to status bar

This commit is contained in:
2025-12-24 00:03:24 +11:00
parent e4848a6e56
commit 9f3a914d0f
4 changed files with 92 additions and 1 deletions

View File

@@ -6,6 +6,19 @@ const path = require('path');
const { initializeDatabase, db, pool } = require('./database');
const GameManager = require('./gameManager');
const { execSync } = require('child_process');
// Capture Git Version Info at Startup
let gitVersion = { hash: 'dev', timestamp: Date.now() / 1000 };
try {
const hash = execSync('git log -1 --format=%h').toString().trim();
const timestamp = parseInt(execSync('git log -1 --format=%ct').toString().trim());
gitVersion = { hash, timestamp };
console.log(`📦 Version: ${hash} (${new Date(timestamp * 1000).toISOString()})`);
} catch (e) {
console.warn('⚠️ Failed to get git version:', e.message);
}
const app = express();
const server = http.createServer(app);
const io = socketIO(server, {
@@ -27,6 +40,11 @@ app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
// Version Endpoint
app.get('/api/version', (req, res) => {
res.json(gitVersion);
});
// Database health check endpoint with detailed diagnostics
app.get('/api/db-status', async (req, res) => {
const startTime = Date.now();