- Organized 252 files across project - Root directory: 187 → 2 files (98.9% reduction) - Moved configuration guides to docs/04-configuration/ - Moved troubleshooting guides to docs/09-troubleshooting/ - Moved quick start guides to docs/01-getting-started/ - Moved reports to reports/ directory - Archived temporary files - Generated comprehensive reports and documentation - Created maintenance scripts and guides All files organized according to established standards.
3.6 KiB
DBIS Source Code Fixes - Final Solution
Date: 2026-01-03
Status: ✅ CUSTOM PATH RESOLVER IMPLEMENTED
Problem
The API service failed with MODULE_NOT_FOUND errors for TypeScript path aliases (@shared/, @/core/, etc.).
Root Cause:
tsconfig-pathsresolves paths based ontsconfig.json, which maps aliases tosrc/*- At runtime, files are in
dist/*, notsrc/* tsconfig-pathswas looking for files insrc/shared/config/envbut they're actually indist/shared/config/env
Solution Implemented
Custom Path Resolver - Created a runtime module resolver that maps TypeScript path aliases directly to the dist directory structure.
Implementation
Created /opt/dbis-core/dist/index-runtime.js that:
- Intercepts Node.js module resolution (
Module._resolveFilename) - Maps path aliases (
@/,@/shared/,@/core/, etc.) todist/*directories - Tries multiple file extensions (
.js,.json, and directoryindex.js) - Falls back to original Node.js resolution if alias doesn't match
Files Created/Modified
/opt/dbis-core/dist/index-runtime.js
This file intercepts require() calls and resolves path aliases to the correct locations in the dist directory.
Key Features:
- Maps
@/→dist/ - Maps
@/shared/→dist/shared/ - Maps
@/core/→dist/core/ - Maps
@/integration/→dist/integration/ - Maps
@/sovereign/→dist/sovereign/ - Maps
@/infrastructure/→dist/infrastructure/
/etc/systemd/system/dbis-api.service
Updated ExecStart to use dist/index-runtime.js instead of dist/index.js.
Verification
After applying the fix:
-
Check service status:
ssh root@192.168.11.10 "pct exec 10150 -- systemctl status dbis-api" -
Check logs:
ssh root@192.168.11.10 "pct exec 10150 -- journalctl -u dbis-api -n 50" -
Test health endpoint:
curl http://192.168.11.155:3000/health -
Verify port listening:
ssh root@192.168.11.10 "pct exec 10150 -- ss -tln | grep 3000"
Applied To
- ✅ VMID 10150 (API Primary)
- ✅ VMID 10151 (API Secondary)
Why This Solution Works
- Direct Mapping: Maps aliases directly to
dist/*without needingtsconfig.jsoninterpretation - Runtime Resolution: Works at runtime without build-time changes
- No Dependencies: Doesn't require
tsconfig-pathspackage (though it's installed) - Flexible: Handles multiple file extensions and directory indexes
- Fallback: Falls back to original Node.js resolution for non-alias imports
Alternative Solutions Considered
- tsconfig-paths: Failed because it resolves to
src/*instead ofdist/* - tsc-alias: Would require rebuild and redeployment (build-time solution)
- Custom resolver: ✅ Chosen - Works immediately at runtime
Next Steps
If the service starts successfully:
- Test API endpoints - Verify the API is responding correctly
- Run database migrations - If needed:
ssh root@192.168.11.10 "pct exec 10150 -- cd /opt/dbis-core && npx prisma migrate deploy" - Test Frontend connectivity - Verify frontend can connect to API
- Monitor logs - Check for any runtime errors
Summary
✅ Custom path resolver implemented
✅ Maps TypeScript aliases to dist directory
✅ Applied to both API containers
✅ Service configured to use runtime entry point
Status: Solution implemented and ready for testing.
Last Updated: 2026-01-03