# DBIS Source Code Fixes - Complete **Date**: 2026-01-03 **Status**: ✅ **PATH RESOLUTION FIXED** - Environment variable issue resolved --- ## Problems Resolved ### 1. ✅ Module Resolution (FIXED) **Issue**: `MODULE_NOT_FOUND: Cannot find module '@shared/config/env'` **Solution**: Created custom path resolver in `/opt/dbis-core/dist/index-runtime.js` that maps TypeScript path aliases directly to the `dist` directory structure. **Status**: ✅ **RESOLVED** - Service now progresses past module resolution errors. ### 2. ✅ Environment Variable (FIXED) **Issue**: `Invalid environment variable JWT_SECRET: JWT_SECRET must be at least 32 characters long` **Solution**: Updated `.env` file to have an actual JWT_SECRET value instead of the shell command `$(openssl rand -hex 32)`. **Status**: ✅ **RESOLVED** - JWT_SECRET now has a proper value. --- ## Solutions Applied ### Custom Path Resolver Created `/opt/dbis-core/dist/index-runtime.js` that: - Intercepts Node.js module resolution - Maps path aliases (`@/`, `@/shared/`, `@/core/`, etc.) to `dist/*` directories - Handles file extensions (`.js`, `.json`) and directory indexes - Falls back to original Node.js resolution ### Environment Variable Fix Updated `.env` files to have proper JWT_SECRET values: - VMID 10150: JWT_SECRET generated and set - VMID 10151: JWT_SECRET generated and set --- ## Files Modified 1. `/opt/dbis-core/dist/index-runtime.js` - Custom path resolver (created) 2. `/opt/dbis-core/.env` - JWT_SECRET updated (VMID 10150, 10151) 3. `/etc/systemd/system/dbis-api.service` - ExecStart updated to use `index-runtime.js` --- ## Verification After fixes: 1. **Service Status**: ```bash ssh root@192.168.11.10 "pct exec 10150 -- systemctl status dbis-api" ``` 2. **Logs**: ```bash ssh root@192.168.11.10 "pct exec 10150 -- journalctl -u dbis-api -n 50" ``` 3. **Port Listening**: ```bash ssh root@192.168.11.10 "pct exec 10150 -- ss -tln | grep 3000" ``` 4. **Health Endpoint**: ```bash curl http://192.168.11.155:3000/health ``` --- ## Applied To - ✅ VMID 10150 (API Primary) - ✅ VMID 10151 (API Secondary) --- ## Summary ✅ **Module resolution**: Fixed with custom path resolver ✅ **Environment variables**: JWT_SECRET properly configured ✅ **Service configuration**: Updated to use runtime entry point ✅ **Both containers**: Changes applied to primary and secondary **Status**: Source code issues resolved. Service should now start successfully (pending any additional runtime errors like database connectivity). --- **Last Updated**: 2026-01-03