@@ -2,11 +2,13 @@ const fs = require('fs/promises');
22const crypto = require ( 'crypto' ) ;
33const http = require ( 'http' ) ;
44const path = require ( 'path' ) ;
5+ const packageJson = require ( '../package.json' ) ;
56
67const ROOT_DIR = path . resolve ( __dirname , '..' ) ;
78const PUBLIC_DIR = path . join ( ROOT_DIR , 'public' ) ;
89const DATA_DIR = path . join ( ROOT_DIR , 'data' ) ;
910const PORT = Number ( process . env . APP_PORT || 8080 ) ;
11+ const APP_VERSION = packageJson . version || '0.0.0' ;
1012const ARANGO_URL = ( process . env . ARANGO_URL || 'http://127.0.0.1:8529' ) . replace ( / \/ $ / , '' ) ;
1113const ARANGO_DB = process . env . ARANGO_DB || 'tables_forms_app' ;
1214const ARANGO_USER = process . env . ARANGO_USER || 'root' ;
@@ -1561,14 +1563,19 @@ async function handleApi(req, res, pathname) {
15611563 if ( req . method === 'GET' && pathname === '/api/health' ) {
15621564 try {
15631565 await ensureDbReady ( ) ;
1564- sendJson ( res , 200 , { ok : true , db : ARANGO_DB } ) ;
1566+ sendJson ( res , 200 , { ok : true , db : ARANGO_DB , version : APP_VERSION } ) ;
15651567 } catch ( err ) {
15661568 console . error ( 'Health check failed:' , err ) ;
1567- sendJson ( res , 503 , { ok : false , error : 'Database is not available' } ) ;
1569+ sendJson ( res , 503 , { ok : false , error : 'Database is not available' , version : APP_VERSION } ) ;
15681570 }
15691571 return ;
15701572 }
15711573
1574+ if ( req . method === 'GET' && pathname === '/api/version' ) {
1575+ sendJson ( res , 200 , { version : APP_VERSION } ) ;
1576+ return ;
1577+ }
1578+
15721579 if ( req . method === 'GET' && pathname === '/api/auth/me' ) {
15731580 const session = requireSession ( req , res ) ;
15741581 if ( ! session ) return ;
0 commit comments