feat: Runtime configuration and Docker deployment improvements

Frontend:
- Add runtime configuration service for deployment-time API URL injection
- Create docker-entrypoint.sh to generate config.json from environment variables
- Update ApiService, ApprovalService, and DocumentViewer to use RuntimeConfigService
- Add APP_INITIALIZER to load runtime config before app starts

Backend:
- Fix init-blockchain.js to properly quote mnemonic phrases in .env file
- Improve docker-entrypoint.sh with health checks and better error handling

Docker:
- Add API_BASE_URL environment variable to frontend container
- Update docker-compose.yml with clear documentation for remote deployment
- Reorganize .env.example with clear categories (REQUIRED FOR REMOTE, PRODUCTION, AUTO-GENERATED)

Workflow fixes:
- Fix DepartmentApproval interface to match backend schema
- Fix stage transformation for 0-indexed stageOrder
- Fix workflow list to show correct stage count from definition.stages

Cleanup:
- Move development artifacts to .trash directory
- Remove root-level package.json (was only for utility scripts)
- Add .trash/ to .gitignore
This commit is contained in:
Mahi
2026-02-08 18:44:05 -04:00
parent 2c10cd5662
commit d9de183e51
171 changed files with 10236 additions and 8386 deletions

View File

@@ -19,7 +19,7 @@ import {
shareReplay,
of,
} from 'rxjs';
import { environment } from '../../../environments/environment';
import { RuntimeConfigService } from './runtime-config.service';
// Configuration constants
const DEFAULT_TIMEOUT_MS = 30000; // 30 seconds
@@ -110,6 +110,12 @@ function extractData<T>(response: ApiResponse<T> | null | undefined): T {
return response as unknown as T;
}
// Handle paginated responses: have 'data' and pagination fields but no 'success'
// These should be returned as-is, not unwrapped
if ('data' in response && !('success' in response) && ('total' in response || 'page' in response)) {
return response as unknown as T;
}
if (response.data === undefined) {
// Return null as T if data is explicitly undefined but response exists
return null as T;
@@ -132,7 +138,14 @@ function isRetryableError(error: HttpErrorResponse): boolean {
})
export class ApiService {
private readonly http = inject(HttpClient);
private readonly baseUrl = environment.apiBaseUrl;
private readonly configService = inject(RuntimeConfigService);
/**
* Get API base URL from runtime config (supports deployment-time configuration)
*/
private get baseUrl(): string {
return this.configService.apiBaseUrl;
}
/**
* Cache for GET requests that should be shared
@@ -331,7 +344,14 @@ export class ApiService {
}
case HttpEventType.Response: {
const responseData = event.body?.data;
// Handle both wrapped ({data: ...}) and unwrapped responses
const body = event.body;
let responseData: T | undefined;
if (body && typeof body === 'object' && 'data' in body) {
responseData = (body as ApiResponse<T>).data;
} else {
responseData = body as T | undefined;
}
return {
progress: 100,
loaded: 1,