Add auto updater
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
import { Router } from 'express';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { getAllPublicServers } from '../cqrs';
|
||||
import { getReleaseManifestUrl } from '../config/variables';
|
||||
import { connectedUsers } from '../websocket/state';
|
||||
|
||||
const router = Router();
|
||||
|
||||
function getServerProjectVersion(): string {
|
||||
try {
|
||||
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
||||
const rawContents = fs.readFileSync(packageJsonPath, 'utf8');
|
||||
const parsed = JSON.parse(rawContents) as { version?: unknown };
|
||||
|
||||
return typeof parsed.version === 'string' && parsed.version.trim().length > 0
|
||||
? parsed.version.trim()
|
||||
: '0.0.0';
|
||||
} catch {
|
||||
return '0.0.0';
|
||||
}
|
||||
}
|
||||
|
||||
router.get('/health', async (_req, res) => {
|
||||
const servers = await getAllPublicServers();
|
||||
|
||||
@@ -11,7 +28,9 @@ router.get('/health', async (_req, res) => {
|
||||
status: 'ok',
|
||||
timestamp: Date.now(),
|
||||
serverCount: servers.length,
|
||||
connectedUsers: connectedUsers.size
|
||||
connectedUsers: connectedUsers.size,
|
||||
serverVersion: getServerProjectVersion(),
|
||||
releaseManifestUrl: getReleaseManifestUrl()
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user