import { DyNTS_RouteSecurity } from '../_enums/route-security.enum'; import { DyNTS_Global_Settings } from '../_models/interfaces/global-settings.interface'; import { DyNTS_SocketSecurity } from '../_modules/socket/_enums/socket-security.enum'; import { DyNTS_getEnvironment_settings } from './get-environment-settings.util'; /** * Default configuration used across the NodeTS framework. * These values can be overridden when bootstrapping the server. */ export const DyNTS_global_settings: DyNTS_Global_Settings = { baseUrl: '/api', systemVersion: 'unknown-version', defaultRouteSecurity: DyNTS_RouteSecurity.open, defaultSocketSecurity: DyNTS_SocketSecurity.open, defaultPageSize: 10, archiveListAfter: 100, env_settings: DyNTS_getEnvironment_settings(), autoResolveEndpointCirculationErrors: true, compactErrorResponse: true, log_settings: { highDetailedLogs: false, setup: false, request: true, requestsContent: false, responseContent: false, requestStackLocation: false, socket_allEvents: true, socket_mainEvents: true, socket_eventContent: false, api_events: true, api_requestContents: false, api_requestSettings: false, api_responseContents: false, api_errors: true, detailedErrors: false, server_debug: false, logs_endpoint: { enabled: false, maxEntries: 2000, }, }, autoResearchIssues: true, // Auth-service kötelező alapból (régi viselkedés). Public / no-auth szervereknél // `auth_settings.optional = true` → getAuthService() undefined-ot ad dobás helyett, // és a startup 'Authentication Service missing!' warn is elmarad. auth_settings: { optional: false, }, bot_settings: null, openAi_settings: null, dias_settings: null, assistant_settings: null, docChunking: { maxChunkSize: 1000, maxChunkCount: 1000, }, // BFR-MASTERPROMPTER-011 / SEC-R2-8 — security response-headerek default-ON (safe-by-default // készlet: x-powered-by removal + SAMEORIGIN + nosniff + strict-origin-when-cross-origin; // HSTS AUTO csak prod-on; CSP opt-in). Per-app tweak az overrideDynamoNTSGlobalSettings()-ben. securityHeaders: { enabled: true, removePoweredBy: true, }, // FR-193 — bedrock OOM korai-figyelmeztető heap-watchdog. Default-on: minden nts-szerver // megkapja a heap-nyomás-figyelést a base App startup-ban (lásd DyNTS_MemoryGuard). Csak // MEGFIGYELÉS + tartós rögzítés a near-OOM küszöböknél — nem változtat a viselkedésen. memoryGuard: { enabled: true, pollIntervalMs: 10000, heapWarningThreshold: 85, heapCriticalThreshold: 95, recoveryMargin: 10, maxHistoryCount: 100, // GC-thrash precursor (a %-küszöb által gyakran KÉSŐN/sosem fogott OOM) + crash-entry + opcionális graceful-exit. gcWarningFraction: 0.40, gcCriticalFraction: 0.60, installCrashHandlers: true, exitOnSustainedCritical: false, sustainedCriticalPolls: 3, exitCode: 137, bootGraceMs: 60000, // Auto-load-shed 503 (BFR-OVERSEER-009 maradék) — opt-in; esszenciális útvonalak kivételével. loadShedEnabled: false, loadShedExemptPathParts: ['/health', '/readiness', '/status', '/diag'], }, // Event-loop-lag diag (BFR-OVERSEER-007) — olcsó natív mérés, default ON (opt-out lehetséges). eventLoopDiag: { enabled: true, pollIntervalMs: 5000, maxHistoryCount: 120, }, // FR-258 / SR-4 — proactive collection-growth monitor (companion to memoryGuard). Periodically // samples each collection's document count (scan-free estimatedDocumentCount) and warns into the // Errors-sink BEFORE an unbounded collection can be loaded into heap and OOM. Observation only — // never deletes (retention SR-1/SR-2 does the deleting). Slow cadence (5 min) — growth is slow. collectionGrowthMonitor: { enabled: true, pollIntervalMs: 300000, sizeThresholdDocCount: 250000, growthRateThresholdPct: 50, reAlertCooldownMs: 3600000, }, };