Initialize model associations in server setup: Import and invoke setupAssociations to ensure all models share the same instance, preventing EagerLoadingError and enhancing data integrity before loading the app and services.

This commit is contained in:
Torsten Schulz (local)
2026-02-04 15:27:46 +01:00
parent 70d1d48fbc
commit ba5e36fa55

View File

@@ -3,6 +3,11 @@ import './config/loadEnv.js'; // .env deterministisch laden
import http from 'http';
import https from 'https';
import fs from 'fs';
// Assoziationen sofort setzen, bevor app (und damit Services/Router) geladen werden.
// So nutzen alle Modelle dieselbe Instanz inkl. Associations (verhindert EagerLoadingError).
import setupAssociations from './models/associations.js';
setupAssociations();
import app from './app.js';
import { setupWebSocket } from './utils/socket.js';
import { syncDatabase } from './utils/syncDatabase.js';