EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
agentVersion.js
Go to the documentation of this file.
1/**
2 * @file agentVersion.js
3 * @module routes/agentVersion
4 * @description Agent version information endpoint. Returns current agent version from package.json.
5 * Used by agents to check for updates and by dashboard to display agent version.
6 * @requires express
7 * @requires fs
8 * @requires path
9 * @author RMM-PSA Development Team
10 * @copyright 2026 RMM-PSA Platform
11 * @license Proprietary
12 */
13
14/**
15 * @apiDefine AgentVersion Agent Version
16 * Agent version information for update checks
17 */
18
19const express = require('express');
20const router = express.Router();
21const fs = require('fs');
22const path = require('path');
23
24/**
25 * @api {get} /api/agent/version Get agent version
26 * @apiName GetAgentVersion
27 * @apiGroup AgentVersion
28 * @apiDescription Retrieve current agent version from package.json.
29 * Returns semantic version string. Fallback to hardcoded version if package.json not found.
30 * Used by agents for update availability checks.
31 * @apiSuccess {string} version Agent version (semantic versioning, e.g., "1.0.12")
32 * @apiExample {curl} Example:
33 * curl -X GET http://localhost:3000/api/agent/version
34 * @apiSuccessExample {json} Success-Response:
35 * HTTP/1.1 200 OK
36 * {
37 * "version": "1.0.12"
38 * }
39 */
40router.get('/version', async (req, res) => {
41 try {
42 // Read version from agent's package.json
43 const agentPackagePath = path.join(__dirname, '../../agent/package.json');
44 if (fs.existsSync(agentPackagePath)) {
45 const agentPackage = JSON.parse(fs.readFileSync(agentPackagePath, 'utf8'));
46 const version = agentPackage.version || '1.0.12';
47 res.json({ version });
48 } else {
49 // Fallback to hardcoded version
50 res.json({ version: '1.0.12' });
51 }
52 } catch (err) {
53 console.error('[AgentVersion] Error:', err);
54 res.json({ version: '1.0.12' });
55 }
56});
57
58module.exports = router;