@futdevpro/nts-dynamo 1.15.64 → 1.15.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.c8rc.json +26 -26
- package/.copilot/patterns.json +7 -7
- package/.cursor/rules/__assistant_guide.mdc +30 -30
- package/.cursor/rules/__main.mdc +64 -64
- package/.cursor/rules/_ag_backend-structure.mdc +85 -85
- package/.cursor/rules/_ag_backend.mdc +16 -16
- package/.cursor/rules/_ag_debug.mdc +7 -7
- package/.cursor/rules/_ag_documentation_writing_rules.mdc +372 -372
- package/.cursor/rules/_ag_file-refactoring.mdc +113 -113
- package/.cursor/rules/_ag_fixes_rules.mdc +5 -5
- package/.cursor/rules/_ag_frontend-structure.mdc +86 -86
- package/.cursor/rules/_ag_frontend.mdc +39 -39
- package/.cursor/rules/_ag_import-rules.mdc +44 -44
- package/.cursor/rules/_ag_naming.mdc +115 -115
- package/.cursor/rules/_ag_running_commands.mdc +4 -4
- package/.cursor/rules/_ag_server-controller.mdc +5 -5
- package/.cursor/rules/_ag_should-be.mdc +6 -6
- package/.cursor/rules/_ag_swearing.mdc +47 -47
- package/.cursor/rules/ai_development_guide.md +60 -60
- package/.cursor/rules/ai_directives.md +114 -114
- package/.cursor/rules/cursor-rules.md +160 -160
- package/.cursor/rules/default-command.mdc +464 -464
- package/.cursor/rules/error_code_pattern.md +39 -39
- package/.cursor/rules/saved rule mcp server use.md +15 -15
- package/.dynamo/pipeline.cicd.config.json +180 -180
- package/.dynamo/version-bump.config.json +5 -5
- package/.github/workflows/main.yml +438 -438
- package/.husky/pre-commit +3 -3
- package/.vscode/settings.json +10 -10
- package/HOWTO.md +15 -15
- package/LICENSE +21 -21
- package/README.md +678 -678
- package/__documentations/2026-04-28-logs-module.md +49 -49
- package/__documentations/2026-05-17-oai-compatible-providers.md +229 -229
- package/__documentations/2026-05-17-static-client-serving-howto.md +144 -144
- package/__documentations/2026-06-01-fr041-cors-middleware.md +96 -96
- package/__documentations/2026-06-01-fr047-p2p3-function-calling.md +81 -81
- package/__documentations/2026-06-15-fr193-memory-guard.md +73 -73
- package/__documentations/nts-integration-tests-2026-03-17.md +26 -26
- package/_specifications/BACKLOG.md +92 -92
- package/_specifications/TODO.md +15 -15
- package/_specifications/agent.md +138 -138
- package/build/_collections/archive.util.d.ts +12 -12
- package/build/_collections/archive.util.js +18 -18
- package/build/_collections/atlas-default-db-options.const.d.ts +2 -2
- package/build/_collections/atlas-default-db-options.const.js +9 -9
- package/build/_collections/default-fallback-cache-max-age.const.d.ts +2 -2
- package/build/_collections/default-fallback-cache-max-age.const.js +5 -5
- package/build/_collections/default-not-found-page.const.d.ts +5 -5
- package/build/_collections/default-not-found-page.const.js +24 -24
- package/build/_collections/default-socket-path.const.d.ts +2 -2
- package/build/_collections/default-socket-path.const.js +5 -5
- package/build/_collections/get-environment-settings.util.d.ts +2 -2
- package/build/_collections/get-environment-settings.util.js +43 -43
- package/build/_collections/global-settings.const.d.ts +6 -6
- package/build/_collections/global-settings.const.js +69 -69
- package/build/_collections/mongo-reconnect-guard.util.d.ts +73 -73
- package/build/_collections/mongo-reconnect-guard.util.js +110 -110
- package/build/_collections/star.controller.d.ts +7 -7
- package/build/_collections/star.controller.js +97 -97
- package/build/_enums/data-model-type.enum.d.ts +13 -13
- package/build/_enums/data-model-type.enum.js +17 -17
- package/build/_enums/data-service-function.enum.d.ts +18 -18
- package/build/_enums/data-service-function.enum.js +24 -24
- package/build/_enums/predefined-data-types.enum.d.ts +15 -15
- package/build/_enums/predefined-data-types.enum.js +19 -19
- package/build/_enums/route-security.enum.d.ts +11 -11
- package/build/_enums/route-security.enum.js +15 -15
- package/build/_models/control-models/api-call-params.control-model.d.ts +79 -79
- package/build/_models/control-models/api-call-params.control-model.js +101 -101
- package/build/_models/control-models/app-ext-system-controls.control-model.d.ts +6 -6
- package/build/_models/control-models/app-ext-system-controls.control-model.js +10 -10
- package/build/_models/control-models/app-params.control-model.d.ts +51 -51
- package/build/_models/control-models/app-params.control-model.js +119 -119
- package/build/_models/control-models/app-system-controls.control-model.d.ts +7 -7
- package/build/_models/control-models/app-system-controls.control-model.js +11 -11
- package/build/_models/control-models/endpoint-params.control-model.d.ts +114 -114
- package/build/_models/control-models/endpoint-params.control-model.js +442 -442
- package/build/_models/control-models/http-settings.control-model.d.ts +17 -17
- package/build/_models/control-models/http-settings.control-model.js +34 -34
- package/build/_models/control-models/system-control.control-model.d.ts +5 -5
- package/build/_models/control-models/system-control.control-model.js +11 -11
- package/build/_models/interfaces/certification-settings.interface.d.ts +5 -5
- package/build/_models/interfaces/certification-settings.interface.js +2 -2
- package/build/_models/interfaces/compare-data-options.interface.d.ts +26 -26
- package/build/_models/interfaces/compare-data-options.interface.js +2 -2
- package/build/_models/interfaces/compare-data-result.interface.d.ts +12 -12
- package/build/_models/interfaces/compare-data-result.interface.js +2 -2
- package/build/_models/interfaces/cors-settings.interface.d.ts +51 -51
- package/build/_models/interfaces/cors-settings.interface.js +2 -2
- package/build/_models/interfaces/environment-settings.interface.d.ts +34 -34
- package/build/_models/interfaces/environment-settings.interface.js +2 -2
- package/build/_models/interfaces/global-log-settings.interface.d.ts +145 -145
- package/build/_models/interfaces/global-log-settings.interface.js +2 -2
- package/build/_models/interfaces/global-service-settings.interface.d.ts +30 -30
- package/build/_models/interfaces/global-service-settings.interface.js +2 -2
- package/build/_models/interfaces/global-settings.interface.d.ts +161 -161
- package/build/_models/interfaces/global-settings.interface.js +2 -2
- package/build/_models/interfaces/routing-module-settings.interface.d.ts +19 -19
- package/build/_models/interfaces/routing-module-settings.interface.js +2 -2
- package/build/_models/interfaces/static-client-settings.interface.d.ts +28 -28
- package/build/_models/interfaces/static-client-settings.interface.js +2 -2
- package/build/_models/types/db-update.type.d.ts +129 -129
- package/build/_models/types/db-update.type.js +2 -2
- package/build/_modules/admin-auth/_models/admin-api-key-config.interface.d.ts +31 -31
- package/build/_modules/admin-auth/_models/admin-api-key-config.interface.js +2 -2
- package/build/_modules/admin-auth/admin-api-key.auth-service.d.ts +89 -89
- package/build/_modules/admin-auth/admin-api-key.auth-service.js +194 -194
- package/build/_modules/admin-auth/index.d.ts +2 -2
- package/build/_modules/admin-auth/index.js +5 -5
- package/build/_modules/ai/_models/ai-input-interfaces.d.ts +53 -53
- package/build/_modules/ai/_models/ai-input-interfaces.js +5 -5
- package/build/_modules/ai/_models/ai-test-generation-result.interface.d.ts +16 -16
- package/build/_modules/ai/_models/ai-test-generation-result.interface.js +2 -2
- package/build/_modules/ai/_models/interfaces/dynts-ai-cost-event-callback.interface.d.ts +13 -13
- package/build/_modules/ai/_models/interfaces/dynts-ai-cost-event-callback.interface.js +2 -2
- package/build/_modules/ai/_models/interfaces/dynts-ai-cost-event.interface.d.ts +49 -49
- package/build/_modules/ai/_models/interfaces/dynts-ai-cost-event.interface.js +2 -2
- package/build/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.d.ts +35 -35
- package/build/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.js +117 -117
- package/build/_modules/ai/_modules/anthropic/index.d.ts +2 -2
- package/build/_modules/ai/_modules/anthropic/index.js +7 -7
- package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.d.ts +84 -84
- package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.js +467 -467
- package/build/_modules/ai/_modules/document-ai/_collections/dai-code-chunking.util.d.ts +109 -109
- package/build/_modules/ai/_modules/document-ai/_collections/dai-code-chunking.util.js +418 -418
- package/build/_modules/ai/_modules/document-ai/_collections/dai-document.util.d.ts +28 -28
- package/build/_modules/ai/_modules/document-ai/_collections/dai-document.util.js +73 -73
- package/build/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.d.ts +6 -6
- package/build/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.js +10 -10
- package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.d.ts +51 -51
- package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.js +132 -132
- package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.d.ts +47 -47
- package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.js +136 -136
- package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.d.ts +17 -17
- package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.js +76 -76
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-code-chunk.interface.d.ts +49 -49
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-code-chunk.interface.js +2 -2
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.d.ts +8 -8
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.js +2 -2
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.d.ts +11 -11
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.js +2 -2
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.d.ts +12 -12
- package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.js +2 -2
- package/build/_modules/ai/_modules/document-ai/index.d.ts +12 -12
- package/build/_modules/ai/_modules/document-ai/index.js +27 -27
- package/build/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.d.ts +34 -34
- package/build/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.js +128 -128
- package/build/_modules/ai/_modules/fdp-ai/index.d.ts +2 -2
- package/build/_modules/ai/_modules/fdp-ai/index.js +7 -7
- package/build/_modules/ai/_modules/open-ai/_collections/oai-global-settings.const.d.ts +2 -2
- package/build/_modules/ai/_modules/open-ai/_collections/oai-global-settings.const.js +8 -8
- package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts +2 -2
- package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js +74 -74
- package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts +2 -2
- package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js +67 -67
- package/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.js +42 -42
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts +5 -5
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js +2 -2
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js +6 -6
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts +51 -51
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js +2 -2
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.d.ts +21 -21
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.js +187 -187
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.d.ts +26 -26
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.js +278 -278
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.d.ts +22 -22
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.js +322 -322
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.d.ts +119 -119
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.js +480 -480
- package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.d.ts +25 -25
- package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.js +103 -103
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts +169 -169
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.js +479 -479
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.d.ts +201 -201
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.js +579 -579
- package/build/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.d.ts +39 -39
- package/build/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.js +110 -110
- package/build/_modules/ai/_modules/open-ai/index.d.ts +14 -14
- package/build/_modules/ai/_modules/open-ai/index.js +55 -55
- package/build/_modules/ai/_services/ai-embedding-mock.service.d.ts +80 -80
- package/build/_modules/ai/_services/ai-embedding-mock.service.js +166 -166
- package/build/_modules/ai/_services/ai-embedding-provider.registry.d.ts +51 -51
- package/build/_modules/ai/_services/ai-embedding-provider.registry.js +78 -78
- package/build/_modules/ai/_services/ai-embedding.service-base.d.ts +41 -41
- package/build/_modules/ai/_services/ai-embedding.service-base.js +11 -11
- package/build/_modules/ai/_services/ai-llm-chat.service-base.d.ts +39 -39
- package/build/_modules/ai/_services/ai-llm-chat.service-base.js +11 -11
- package/build/_modules/ai/_services/ai-llm.service-base.d.ts +132 -132
- package/build/_modules/ai/_services/ai-llm.service-base.js +313 -313
- package/build/_modules/ai/_services/ai-provider.service-base.d.ts +46 -46
- package/build/_modules/ai/_services/ai-provider.service-base.js +43 -43
- package/build/_modules/ai/_services/ai-user-key.service-base.d.ts +44 -44
- package/build/_modules/ai/_services/ai-user-key.service-base.js +14 -14
- package/build/_modules/ai/_services/lmstudio-embedding.control-service.d.ts +110 -110
- package/build/_modules/ai/_services/lmstudio-embedding.control-service.js +297 -297
- package/build/_modules/ai/index.d.ts +13 -13
- package/build/_modules/ai/index.js +22 -22
- package/build/_modules/assistant/_collections/ass-global-settings.const.d.ts +2 -2
- package/build/_modules/assistant/_collections/ass-global-settings.const.js +14 -14
- package/build/_modules/assistant/_collections/ass.util.d.ts +15 -15
- package/build/_modules/assistant/_collections/ass.util.js +42 -42
- package/build/_modules/assistant/_models/ass-global-settings.interface.d.ts +13 -13
- package/build/_modules/assistant/_models/ass-global-settings.interface.js +2 -2
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts +19 -19
- package/build/_modules/assistant/_services/ass-io.control-service.js +57 -57
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts +32 -32
- package/build/_modules/assistant/_services/ass-main.control-service.js +65 -65
- package/build/_modules/assistant/index.d.ts +6 -6
- package/build/_modules/assistant/index.js +18 -18
- package/build/_modules/bot/_collections/bot-default-commands.const.d.ts +2 -2
- package/build/_modules/bot/_collections/bot-default-commands.const.js +13 -13
- package/build/_modules/bot/_collections/bot-global-settings.const.d.ts +2 -2
- package/build/_modules/bot/_collections/bot-global-settings.const.js +31 -31
- package/build/_modules/bot/_models/bot-channel-wrapper.interface.d.ts +25 -25
- package/build/_modules/bot/_models/bot-channel-wrapper.interface.js +38 -38
- package/build/_modules/bot/_models/bot-command.interface.d.ts +7 -7
- package/build/_modules/bot/_models/bot-command.interface.js +2 -2
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts +85 -85
- package/build/_modules/bot/_models/bot-global-settings.interface.js +2 -2
- package/build/_modules/bot/_models/bot-last-mention-date.interface.d.ts +6 -6
- package/build/_modules/bot/_models/bot-last-mention-date.interface.js +2 -2
- package/build/_modules/bot/_models/bot-last-message-date.interface.d.ts +5 -5
- package/build/_modules/bot/_models/bot-last-message-date.interface.js +2 -2
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts +37 -37
- package/build/_modules/bot/_models/bot-message-wrapper.interface.js +54 -54
- package/build/_modules/bot/_models/bot-user-wrapper.interface.d.ts +23 -23
- package/build/_modules/bot/_models/bot-user-wrapper.interface.js +28 -28
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js +10 -10
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.d.ts +69 -69
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.js +497 -497
- package/build/_modules/bot/_modules/discord-bot/index.d.ts +1 -1
- package/build/_modules/bot/_modules/discord-bot/index.js +12 -12
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.d.ts +16 -16
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.js +42 -42
- package/build/_modules/bot/_modules/dynamo-bot/_models/dyb-platform.types.d.ts +9 -9
- package/build/_modules/bot/_modules/dynamo-bot/_models/dyb-platform.types.js +2 -2
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.d.ts +59 -59
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.js +349 -349
- package/build/_modules/bot/_modules/dynamo-bot/index.d.ts +3 -3
- package/build/_modules/bot/_modules/dynamo-bot/index.js +15 -15
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts +6 -6
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.js +2 -2
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.d.ts +56 -56
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.js +137 -137
- package/build/_modules/bot/_modules/slack-bot/index.d.ts +2 -2
- package/build/_modules/bot/_modules/slack-bot/index.js +12 -12
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts +6 -6
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.js +2 -2
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.d.ts +56 -56
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.js +137 -137
- package/build/_modules/bot/_modules/teams-bot/index.d.ts +2 -2
- package/build/_modules/bot/_modules/teams-bot/index.js +12 -12
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts +12 -12
- package/build/_modules/bot/_services/bot-commands.control-service.js +117 -117
- package/build/_modules/bot/_services/bot-io.control-service.d.ts +23 -23
- package/build/_modules/bot/_services/bot-io.control-service.js +226 -226
- package/build/_modules/bot/_services/bot-main.control-service.d.ts +35 -35
- package/build/_modules/bot/_services/bot-main.control-service.js +195 -195
- package/build/_modules/bot/_services/bot-messaging-provider.service-base.d.ts +71 -71
- package/build/_modules/bot/_services/bot-messaging-provider.service-base.js +15 -15
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts +13 -13
- package/build/_modules/bot/_services/bot-routines.control-service.js +59 -59
- package/build/_modules/bot/index.d.ts +17 -17
- package/build/_modules/bot/index.js +36 -36
- package/build/_modules/custom-data/custom-data.controller.d.ts +5 -5
- package/build/_modules/custom-data/custom-data.controller.js +56 -56
- package/build/_modules/custom-data/custom-data.data-service.d.ts +5 -5
- package/build/_modules/custom-data/custom-data.data-service.js +11 -11
- package/build/_modules/custom-data/get-custom-data-routing-module.util.d.ts +3 -3
- package/build/_modules/custom-data/get-custom-data-routing-module.util.js +16 -16
- package/build/_modules/custom-data/index.d.ts +4 -4
- package/build/_modules/custom-data/index.js +9 -9
- package/build/_modules/data-readers/_collections/dynts-sqlite-reader.util.d.ts +58 -58
- package/build/_modules/data-readers/_collections/dynts-sqlite-reader.util.js +168 -168
- package/build/_modules/data-readers/_models/interfaces/dynts-sqlite-reader.interface.d.ts +31 -31
- package/build/_modules/data-readers/_models/interfaces/dynts-sqlite-reader.interface.js +7 -7
- package/build/_modules/data-readers/index.d.ts +2 -2
- package/build/_modules/data-readers/index.js +10 -10
- package/build/_modules/defaults/_collections/default-endpoints.util.d.ts +248 -248
- package/build/_modules/defaults/_collections/default-endpoints.util.js +386 -386
- package/build/_modules/defaults/_models/default-user.data-model.d.ts +19 -19
- package/build/_modules/defaults/_models/default-user.data-model.js +72 -72
- package/build/_modules/defaults/_services/default-auth.service.d.ts +50 -50
- package/build/_modules/defaults/_services/default-auth.service.js +158 -158
- package/build/_modules/defaults/_services/default-socket-events.service.d.ts +23 -23
- package/build/_modules/defaults/_services/default-socket-events.service.js +60 -60
- package/build/_modules/defaults/_services/default-user.data-service.d.ts +24 -24
- package/build/_modules/defaults/_services/default-user.data-service.js +87 -87
- package/build/_modules/defaults/index.d.ts +5 -5
- package/build/_modules/defaults/index.js +17 -17
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts +2 -2
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js +16 -16
- package/build/_modules/discord-assistant/_collections/dias.util.d.ts +31 -31
- package/build/_modules/discord-assistant/_collections/dias.util.js +85 -85
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts +17 -17
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js +2 -2
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts +8 -8
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js +46 -46
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +17 -17
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +123 -123
- package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts +10 -10
- package/build/_modules/discord-assistant/_services/dias-io.control-service.js +49 -49
- package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts +3 -3
- package/build/_modules/discord-assistant/_services/dias-main.control-service.js +7 -7
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +18 -18
- package/build/_modules/discord-assistant/_services/dias.service-base.js +46 -46
- package/build/_modules/discord-assistant/index.d.ts +11 -11
- package/build/_modules/discord-assistant/index.js +24 -24
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts +3 -3
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js +7 -7
- package/build/_modules/discord-assistant-voiced/index.d.ts +2 -2
- package/build/_modules/discord-assistant-voiced/index.js +28 -28
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts +2 -2
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js +12 -12
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts +2 -2
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js +43 -43
- package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts +22 -22
- package/build/_modules/discord-bot/_collections/dibo-operations.util.js +275 -275
- package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts +7 -7
- package/build/_modules/discord-bot/_models/dibo-command.interface.js +2 -2
- package/build/_modules/discord-bot/_models/dibo-global-settings.interface.d.ts +87 -87
- package/build/_modules/discord-bot/_models/dibo-global-settings.interface.js +2 -2
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts +6 -6
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js +2 -2
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts +5 -5
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js +2 -2
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts +11 -11
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.js +109 -109
- package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts +21 -21
- package/build/_modules/discord-bot/_services/dibo-io.control-service.js +218 -218
- package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts +89 -89
- package/build/_modules/discord-bot/_services/dibo-main.control-service.js +363 -363
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts +13 -13
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.js +73 -73
- package/build/_modules/discord-bot/index.d.ts +11 -11
- package/build/_modules/discord-bot/index.js +30 -30
- package/build/_modules/local-vector-search/_enums/lvs-search-mode.enum.d.ts +34 -34
- package/build/_modules/local-vector-search/_enums/lvs-search-mode.enum.js +38 -38
- package/build/_modules/local-vector-search/_models/data-models/lvs-vector-persist.data-model.d.ts +35 -35
- package/build/_modules/local-vector-search/_models/data-models/lvs-vector-persist.data-model.js +53 -53
- package/build/_modules/local-vector-search/_models/lvs-search-result.interface.d.ts +16 -16
- package/build/_modules/local-vector-search/_models/lvs-search-result.interface.js +2 -2
- package/build/_modules/local-vector-search/_services/lvs-bm25.util.d.ts +88 -88
- package/build/_modules/local-vector-search/_services/lvs-bm25.util.js +189 -189
- package/build/_modules/local-vector-search/_services/lvs-doc-chunk-data.service.d.ts +26 -26
- package/build/_modules/local-vector-search/_services/lvs-doc-chunk-data.service.js +197 -197
- package/build/_modules/local-vector-search/_services/lvs-local-vector-search.data-service.d.ts +145 -145
- package/build/_modules/local-vector-search/_services/lvs-local-vector-search.data-service.js +294 -294
- package/build/_modules/local-vector-search/_services/lvs-persistent-vector-pool.control-service.d.ts +69 -69
- package/build/_modules/local-vector-search/_services/lvs-persistent-vector-pool.control-service.js +122 -122
- package/build/_modules/local-vector-search/_services/lvs-vector-persist.data-service.d.ts +42 -42
- package/build/_modules/local-vector-search/_services/lvs-vector-persist.data-service.js +71 -71
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.d.ts +70 -70
- package/build/_modules/local-vector-search/_services/lvs-vector-pool.control-service.js +181 -181
- package/build/_modules/local-vector-search/index.d.ts +8 -8
- package/build/_modules/local-vector-search/index.js +15 -15
- package/build/_modules/logs/_models/file-log-entry.interface.d.ts +13 -13
- package/build/_modules/logs/_models/file-log-entry.interface.js +2 -2
- package/build/_modules/logs/_models/file-log-read-result.interface.d.ts +35 -35
- package/build/_modules/logs/_models/file-log-read-result.interface.js +2 -2
- package/build/_modules/logs/file-log.service.d.ts +132 -132
- package/build/_modules/logs/file-log.service.js +444 -444
- package/build/_modules/logs/file-logs.controller.d.ts +40 -40
- package/build/_modules/logs/file-logs.controller.js +138 -138
- package/build/_modules/logs/get-file-logs-routing-module.util.d.ts +31 -31
- package/build/_modules/logs/get-file-logs-routing-module.util.js +37 -37
- package/build/_modules/logs/get-logs-routing-module.util.d.ts +18 -18
- package/build/_modules/logs/get-logs-routing-module.util.js +31 -31
- package/build/_modules/logs/index.d.ts +8 -8
- package/build/_modules/logs/index.js +15 -15
- package/build/_modules/logs/log-buffer.service.d.ts +37 -37
- package/build/_modules/logs/log-buffer.service.js +96 -96
- package/build/_modules/logs/logs.controller.d.ts +26 -26
- package/build/_modules/logs/logs.controller.js +89 -89
- package/build/_modules/logs/logs.service.d.ts +39 -39
- package/build/_modules/logs/logs.service.js +96 -96
- package/build/_modules/mcp/_models/interfaces/dynts-mcp.interface.d.ts +108 -108
- package/build/_modules/mcp/_models/interfaces/dynts-mcp.interface.js +13 -13
- package/build/_modules/mcp/_services/dynts-mcp-server.service-base.d.ts +70 -70
- package/build/_modules/mcp/_services/dynts-mcp-server.service-base.js +98 -98
- package/build/_modules/mcp/_services/dynts-mcp.adapter.d.ts +56 -56
- package/build/_modules/mcp/_services/dynts-mcp.adapter.js +138 -138
- package/build/_modules/mcp/index.d.ts +3 -3
- package/build/_modules/mcp/index.js +12 -12
- package/build/_modules/messaging/_collections/get-messaging-routing-module.util.d.ts +7 -7
- package/build/_modules/messaging/_collections/get-messaging-routing-module.util.js +20 -20
- package/build/_modules/messaging/_collections/msg-global-settings.const.d.ts +5 -5
- package/build/_modules/messaging/_collections/msg-global-settings.const.js +22 -22
- package/build/_modules/messaging/_collections/msg.util.d.ts +24 -24
- package/build/_modules/messaging/_collections/msg.util.js +62 -62
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts +28 -28
- package/build/_modules/messaging/_models/msg-global-settings.interface.js +2 -2
- package/build/_modules/messaging/_services/msg-conversation.data-service.d.ts +28 -28
- package/build/_modules/messaging/_services/msg-conversation.data-service.js +109 -109
- package/build/_modules/messaging/_services/msg-events.service.d.ts +61 -61
- package/build/_modules/messaging/_services/msg-events.service.js +203 -203
- package/build/_modules/messaging/_services/msg-integration.control-service.js +180 -180
- package/build/_modules/messaging/_services/msg-main.control-service.d.ts +62 -62
- package/build/_modules/messaging/_services/msg-main.control-service.js +428 -428
- package/build/_modules/messaging/_services/msg-message.data-service.d.ts +28 -28
- package/build/_modules/messaging/_services/msg-message.data-service.js +103 -103
- package/build/_modules/messaging/_services/msg.controller.d.ts +12 -12
- package/build/_modules/messaging/_services/msg.controller.js +256 -256
- package/build/_modules/messaging/index.d.ts +10 -10
- package/build/_modules/messaging/index.js +27 -27
- package/build/_modules/mock/app-extended-server.mock.d.ts +41 -41
- package/build/_modules/mock/app-extended-server.mock.js +169 -169
- package/build/_modules/mock/app-integration-test.mock.d.ts +19 -19
- package/build/_modules/mock/app-integration-test.mock.js +45 -45
- package/build/_modules/mock/app-params.mock.d.ts +2 -2
- package/build/_modules/mock/app-params.mock.js +9 -9
- package/build/_modules/mock/app-server.mock.d.ts +41 -41
- package/build/_modules/mock/app-server.mock.js +148 -148
- package/build/_modules/mock/auth-service.mock.d.ts +10 -10
- package/build/_modules/mock/auth-service.mock.js +19 -19
- package/build/_modules/mock/controller.mock.d.ts +5 -5
- package/build/_modules/mock/controller.mock.js +14 -14
- package/build/_modules/mock/data-model.mock.d.ts +26 -26
- package/build/_modules/mock/data-model.mock.js +72 -72
- package/build/_modules/mock/email-service-collection.mock.d.ts +7 -7
- package/build/_modules/mock/email-service-collection.mock.js +12 -12
- package/build/_modules/mock/email-service.mock.d.ts +4 -4
- package/build/_modules/mock/email-service.mock.js +20 -20
- package/build/_modules/mock/endpoint.mock.d.ts +8 -8
- package/build/_modules/mock/endpoint.mock.js +79 -79
- package/build/_modules/mock/socket-client.mock.d.ts +9 -9
- package/build/_modules/mock/socket-client.mock.js +38 -38
- package/build/_modules/mock/socket-server.mock.d.ts +15 -15
- package/build/_modules/mock/socket-server.mock.js +32 -32
- package/build/_modules/oauth2/_routes/oauth2.controller.d.ts +16 -16
- package/build/_modules/oauth2/_routes/oauth2.controller.js +96 -96
- package/build/_modules/oauth2/_services/oauth2.auth-service.d.ts +30 -30
- package/build/_modules/oauth2/_services/oauth2.auth-service.js +215 -215
- package/build/_modules/oauth2/_services/oauth2.control-service.d.ts +132 -132
- package/build/_modules/oauth2/_services/oauth2.control-service.js +576 -576
- package/build/_modules/oauth2/index.d.ts +3 -3
- package/build/_modules/oauth2/index.js +14 -14
- package/build/_modules/rate-limit/_models/rate-limit-config.interface.d.ts +61 -61
- package/build/_modules/rate-limit/_models/rate-limit-config.interface.js +2 -2
- package/build/_modules/rate-limit/_models/rate-limit-policy.interface.d.ts +15 -15
- package/build/_modules/rate-limit/_models/rate-limit-policy.interface.js +2 -2
- package/build/_modules/rate-limit/index.d.ts +3 -3
- package/build/_modules/rate-limit/index.js +5 -5
- package/build/_modules/rate-limit/rate-limit.middleware.d.ts +132 -132
- package/build/_modules/rate-limit/rate-limit.middleware.js +289 -289
- package/build/_modules/scoped-config/_enums/dynts-scoped-config-level.enum.d.ts +18 -18
- package/build/_modules/scoped-config/_enums/dynts-scoped-config-level.enum.js +22 -22
- package/build/_modules/scoped-config/_models/data-models/dynts-scoped-config.data-model.d.ts +43 -43
- package/build/_modules/scoped-config/_models/data-models/dynts-scoped-config.data-model.js +67 -67
- package/build/_modules/scoped-config/_models/interfaces/dynts-scoped-config.interface.d.ts +88 -88
- package/build/_modules/scoped-config/_models/interfaces/dynts-scoped-config.interface.js +11 -11
- package/build/_modules/scoped-config/_services/dynts-scoped-config.control-service.d.ts +83 -83
- package/build/_modules/scoped-config/_services/dynts-scoped-config.control-service.js +219 -219
- package/build/_modules/scoped-config/_services/dynts-scoped-config.data-service.d.ts +53 -53
- package/build/_modules/scoped-config/_services/dynts-scoped-config.data-service.js +75 -75
- package/build/_modules/scoped-config/index.d.ts +5 -5
- package/build/_modules/scoped-config/index.js +14 -14
- package/build/_modules/server/errors/errors.control-service.d.ts +21 -19
- package/build/_modules/server/errors/errors.control-service.d.ts.map +1 -1
- package/build/_modules/server/errors/errors.control-service.js +10 -10
- package/build/_modules/server/errors/errors.control-service.js.map +1 -1
- package/build/_modules/server/errors/errors.controller.d.ts +100 -99
- package/build/_modules/server/errors/errors.controller.d.ts.map +1 -1
- package/build/_modules/server/errors/errors.controller.js +355 -313
- package/build/_modules/server/errors/errors.controller.js.map +1 -1
- package/build/_modules/server/errors/errors.data-service.d.ts +64 -47
- package/build/_modules/server/errors/errors.data-service.d.ts.map +1 -1
- package/build/_modules/server/errors/errors.data-service.js +628 -552
- package/build/_modules/server/errors/errors.data-service.js.map +1 -1
- package/build/_modules/server/index.d.ts +7 -7
- package/build/_modules/server/index.js +26 -26
- package/build/_modules/server/server-status/server-status-snapshot.control-service.d.ts +4 -4
- package/build/_modules/server/server-status/server-status-snapshot.control-service.js +7 -7
- package/build/_modules/server/server-status/server-status-snapshot.data-service.d.ts +6 -6
- package/build/_modules/server/server-status/server-status-snapshot.data-service.js +22 -22
- package/build/_modules/server/server-status/server-status.control-service.d.ts +74 -74
- package/build/_modules/server/server-status/server-status.control-service.js +234 -234
- package/build/_modules/server/server-status/server-status.controller.d.ts +84 -84
- package/build/_modules/server/server-status/server-status.controller.js +172 -172
- package/build/_modules/socket/_enums/socket-security.enum.d.ts +10 -10
- package/build/_modules/socket/_enums/socket-security.enum.js +14 -14
- package/build/_modules/socket/_models/socket-client-service-params.control-model.d.ts +8 -8
- package/build/_modules/socket/_models/socket-client-service-params.control-model.js +16 -16
- package/build/_modules/socket/_models/socket-presence.control-model.d.ts +25 -25
- package/build/_modules/socket/_models/socket-presence.control-model.js +139 -139
- package/build/_modules/socket/_models/socket-server-service-params.control-model.d.ts +12 -12
- package/build/_modules/socket/_models/socket-server-service-params.control-model.js +20 -20
- package/build/_modules/socket/_services/socket-client.service.d.ts +37 -37
- package/build/_modules/socket/_services/socket-client.service.js +196 -196
- package/build/_modules/socket/_services/socket-server.service.d.ts +94 -94
- package/build/_modules/socket/_services/socket-server.service.js +689 -689
- package/build/_modules/socket/app-extended.server.d.ts +145 -145
- package/build/_modules/socket/app-extended.server.js +506 -506
- package/build/_modules/socket/index.d.ts +8 -8
- package/build/_modules/socket/index.js +35 -35
- package/build/_modules/test/get-test-routing-module.util.d.ts +3 -3
- package/build/_modules/test/get-test-routing-module.util.js +16 -16
- package/build/_modules/test/index.d.ts +3 -3
- package/build/_modules/test/index.js +11 -11
- package/build/_modules/test/test.controller.d.ts +5 -5
- package/build/_modules/test/test.controller.js +103 -103
- package/build/_modules/usage/get-usage-routing-module.util.d.ts +3 -3
- package/build/_modules/usage/get-usage-routing-module.util.js +16 -16
- package/build/_modules/usage/index.d.ts +4 -4
- package/build/_modules/usage/index.js +13 -13
- package/build/_modules/usage/usage.controller.d.ts +6 -6
- package/build/_modules/usage/usage.controller.js +95 -95
- package/build/_modules/usage/usage.data-service.d.ts +17 -17
- package/build/_modules/usage/usage.data-service.js +135 -135
- package/build/_services/base/api.service-base.d.ts +9 -9
- package/build/_services/base/api.service-base.js +46 -46
- package/build/_services/base/archive-data.service.d.ts +25 -25
- package/build/_services/base/archive-data.service.js +140 -140
- package/build/_services/base/data.service.d.ts +381 -381
- package/build/_services/base/data.service.js +2068 -2068
- package/build/_services/base/db.service.d.ts +393 -393
- package/build/_services/base/db.service.js +1256 -1256
- package/build/_services/base/singleton.service-base.d.ts +8 -8
- package/build/_services/base/singleton.service-base.js +21 -21
- package/build/_services/base/singleton.service.d.ts +11 -11
- package/build/_services/base/singleton.service.js +31 -31
- package/build/_services/core/api.service.d.ts +45 -45
- package/build/_services/core/api.service.js +436 -436
- package/build/_services/core/auth.service.d.ts +129 -129
- package/build/_services/core/auth.service.js +59 -59
- package/build/_services/core/email.service.d.ts +77 -77
- package/build/_services/core/email.service.js +489 -489
- package/build/_services/core/global.service.d.ts +76 -76
- package/build/_services/core/global.service.js +370 -370
- package/build/_services/core/memory-guard.service.d.ts +110 -110
- package/build/_services/core/memory-guard.service.js +197 -197
- package/build/_services/core/service-collection.service.d.ts +4 -4
- package/build/_services/core/service-collection.service.js +7 -7
- package/build/_services/route/controller.service.d.ts +124 -124
- package/build/_services/route/controller.service.js +95 -95
- package/build/_services/route/routing-module.service.d.ts +80 -80
- package/build/_services/route/routing-module.service.js +250 -250
- package/build/_services/server/app.server.d.ts +352 -352
- package/build/_services/server/app.server.js +1323 -1323
- package/build/_services/shared.static-service.d.ts +36 -36
- package/build/_services/shared.static-service.js +72 -72
- package/build/index.d.ts +43 -43
- package/build/index.js +80 -80
- package/eslint.config.js +3 -3
- package/nodemon.json +24 -24
- package/package.json +416 -417
- package/pnpm-workspace.yaml +5 -5
- package/scripts/run-coverage-tests.js +28 -28
- package/spec/support/helpers/spec-reporter-loader.js +359 -359
- package/spec/support/helpers/ts-node-helper.js +93 -93
- package/spec/support/jasmine.coverage.json +24 -24
- package/spec/support/jasmine.json +24 -24
- package/src/_collections/archive.util.spec.ts +57 -57
- package/src/_collections/archive.util.ts +18 -18
- package/src/_collections/atlas-default-db-options.const.ts +9 -9
- package/src/_collections/default-fallback-cache-max-age.const.spec.ts +11 -11
- package/src/_collections/default-fallback-cache-max-age.const.ts +2 -2
- package/src/_collections/default-not-found-page.const.spec.ts +19 -19
- package/src/_collections/default-not-found-page.const.ts +22 -22
- package/src/_collections/default-socket-path.const.spec.ts +12 -12
- package/src/_collections/default-socket-path.const.ts +2 -2
- package/src/_collections/get-environment-settings.util.spec.ts +210 -210
- package/src/_collections/get-environment-settings.util.ts +48 -48
- package/src/_collections/global-settings.const.ts +89 -89
- package/src/_collections/mongo-reconnect-guard.util.spec.ts +52 -52
- package/src/_collections/mongo-reconnect-guard.util.ts +172 -172
- package/src/_collections/sample.env +21 -21
- package/src/_collections/star.controller.spec.ts +224 -224
- package/src/_collections/star.controller.ts +129 -129
- package/src/_enums/data-model-type.enum.ts +14 -14
- package/src/_enums/data-service-function.enum.ts +24 -24
- package/src/_enums/predefined-data-types.enum.ts +16 -16
- package/src/_enums/route-security.enum.ts +12 -12
- package/src/_models/control-models/api-call-params.control-model.spec.ts +152 -152
- package/src/_models/control-models/api-call-params.control-model.ts +142 -142
- package/src/_models/control-models/app-ext-system-controls.control-model.spec.ts +52 -52
- package/src/_models/control-models/app-ext-system-controls.control-model.ts +9 -9
- package/src/_models/control-models/app-params.control-model.spec.ts +225 -225
- package/src/_models/control-models/app-params.control-model.ts +136 -136
- package/src/_models/control-models/app-system-controls.control-model.spec.ts +31 -31
- package/src/_models/control-models/app-system-controls.control-model.ts +9 -9
- package/src/_models/control-models/endpoint-params.control-model.spec.ts +627 -627
- package/src/_models/control-models/endpoint-params.control-model.ts +627 -627
- package/src/_models/control-models/http-settings.control-model.spec.ts +77 -77
- package/src/_models/control-models/http-settings.control-model.ts +37 -37
- package/src/_models/control-models/system-control.control-model.spec.ts +27 -27
- package/src/_models/control-models/system-control.control-model.ts +12 -12
- package/src/_models/interfaces/certification-settings.interface.ts +7 -7
- package/src/_models/interfaces/compare-data-options.interface.ts +27 -27
- package/src/_models/interfaces/compare-data-result.interface.ts +12 -12
- package/src/_models/interfaces/cors-settings.interface.spec.ts +52 -52
- package/src/_models/interfaces/cors-settings.interface.ts +56 -56
- package/src/_models/interfaces/environment-settings.interface.ts +59 -59
- package/src/_models/interfaces/global-log-settings.interface.ts +171 -171
- package/src/_models/interfaces/global-service-settings.interface.ts +47 -47
- package/src/_models/interfaces/global-settings.interface.ts +185 -185
- package/src/_models/interfaces/routing-module-settings.interface.ts +21 -21
- package/src/_models/interfaces/static-client-settings.interface.spec.ts +29 -29
- package/src/_models/interfaces/static-client-settings.interface.ts +28 -28
- package/src/_models/types/db-update.type.ts +100 -100
- package/src/_modules/admin-auth/_models/admin-api-key-config.interface.ts +33 -33
- package/src/_modules/admin-auth/admin-api-key.auth-service.spec.ts +200 -200
- package/src/_modules/admin-auth/admin-api-key.auth-service.ts +220 -220
- package/src/_modules/admin-auth/index.ts +2 -2
- package/src/_modules/ai/_models/ai-input-interfaces.ts +117 -117
- package/src/_modules/ai/_models/ai-test-generation-result.interface.ts +16 -16
- package/src/_modules/ai/_models/interfaces/dynts-ai-cost-event-callback.interface.ts +14 -14
- package/src/_modules/ai/_models/interfaces/dynts-ai-cost-event.interface.ts +56 -56
- package/src/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.ts +138 -138
- package/src/_modules/ai/_modules/anthropic/index.ts +5 -5
- package/src/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.spec.ts +242 -242
- package/src/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.ts +639 -639
- package/src/_modules/ai/_modules/document-ai/_collections/dai-code-chunking.util.spec.ts +295 -295
- package/src/_modules/ai/_modules/document-ai/_collections/dai-code-chunking.util.ts +552 -552
- package/src/_modules/ai/_modules/document-ai/_collections/dai-document.util.spec.ts +209 -209
- package/src/_modules/ai/_modules/document-ai/_collections/dai-document.util.ts +85 -85
- package/src/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.ts +7 -7
- package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.ts +146 -146
- package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.ts +162 -162
- package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.ts +99 -99
- package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-code-chunk.interface.ts +68 -68
- package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.ts +18 -18
- package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.ts +19 -19
- package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.ts +25 -25
- package/src/_modules/ai/_modules/document-ai/index.ts +30 -30
- package/src/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.ts +189 -189
- package/src/_modules/ai/_modules/fdp-ai/index.ts +5 -5
- package/src/_modules/ai/_modules/open-ai/_collections/oai-global-settings.const.ts +9 -9
- package/src/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.ts +82 -82
- package/src/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.ts +75 -75
- package/src/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.ts +45 -45
- package/src/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.ts +7 -7
- package/src/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.ts +7 -7
- package/src/_modules/ai/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.ts +57 -57
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.ts +292 -292
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.ts +572 -572
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.spec.ts +342 -342
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.ts +435 -435
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.spec.ts +550 -550
- package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.ts +630 -630
- package/src/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.spec.ts +332 -332
- package/src/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.ts +132 -132
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.spec.ts +462 -462
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.ts +634 -634
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.spec.ts +489 -489
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.tools.spec.ts +173 -173
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.ts +1033 -1033
- package/src/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.ts +157 -157
- package/src/_modules/ai/_modules/open-ai/index.ts +74 -74
- package/src/_modules/ai/_services/ai-embedding-mock.service.spec.ts +115 -115
- package/src/_modules/ai/_services/ai-embedding-mock.service.ts +233 -233
- package/src/_modules/ai/_services/ai-embedding-provider.registry.spec.ts +110 -110
- package/src/_modules/ai/_services/ai-embedding-provider.registry.ts +114 -114
- package/src/_modules/ai/_services/ai-embedding.service-base.spec.ts +98 -98
- package/src/_modules/ai/_services/ai-embedding.service-base.ts +48 -48
- package/src/_modules/ai/_services/ai-llm-chat.service-base.spec.ts +229 -229
- package/src/_modules/ai/_services/ai-llm-chat.service-base.ts +68 -68
- package/src/_modules/ai/_services/ai-llm.service-base.spec.ts +250 -250
- package/src/_modules/ai/_services/ai-llm.service-base.ts +519 -519
- package/src/_modules/ai/_services/ai-provider.service-base.spec.ts +158 -158
- package/src/_modules/ai/_services/ai-provider.service-base.ts +67 -67
- package/src/_modules/ai/_services/ai-user-key.service-base.ts +59 -59
- package/src/_modules/ai/_services/lmstudio-embedding.control-service.spec.ts +197 -197
- package/src/_modules/ai/_services/lmstudio-embedding.control-service.ts +399 -399
- package/src/_modules/ai/index.ts +23 -23
- package/src/_modules/assistant/_collections/ass-global-settings.const.ts +13 -13
- package/src/_modules/assistant/_collections/ass.util.spec.ts +176 -176
- package/src/_modules/assistant/_collections/ass.util.ts +50 -50
- package/src/_modules/assistant/_models/ass-global-settings.interface.ts +15 -15
- package/src/_modules/assistant/_services/ass-io.control-service.spec.ts +140 -140
- package/src/_modules/assistant/_services/ass-io.control-service.ts +74 -74
- package/src/_modules/assistant/_services/ass-main.control-service.spec.ts +192 -192
- package/src/_modules/assistant/_services/ass-main.control-service.ts +107 -107
- package/src/_modules/assistant/index.ts +19 -19
- package/src/_modules/bot/_collections/bot-default-commands.const.ts +12 -12
- package/src/_modules/bot/_collections/bot-global-settings.const.ts +39 -39
- package/src/_modules/bot/_models/bot-channel-wrapper.interface.ts +62 -62
- package/src/_modules/bot/_models/bot-command.interface.ts +8 -8
- package/src/_modules/bot/_models/bot-global-settings.interface.ts +96 -96
- package/src/_modules/bot/_models/bot-last-mention-date.interface.ts +6 -6
- package/src/_modules/bot/_models/bot-last-message-date.interface.ts +5 -5
- package/src/_modules/bot/_models/bot-message-wrapper.interface.ts +90 -90
- package/src/_modules/bot/_models/bot-user-wrapper.interface.ts +41 -41
- package/src/_modules/bot/_modules/discord-bot/_models/dib-platform.types.ts +9 -9
- package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.spec.ts +431 -431
- package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.ts +641 -641
- package/src/_modules/bot/_modules/discord-bot/index.ts +12 -12
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.spec.ts +160 -160
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.ts +55 -55
- package/src/_modules/bot/_modules/dynamo-bot/_models/dyb-platform.types.ts +15 -15
- package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.spec.ts +374 -374
- package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.ts +447 -447
- package/src/_modules/bot/_modules/dynamo-bot/index.ts +15 -15
- package/src/_modules/bot/_modules/slack-bot/_models/slb-platform.types.ts +9 -9
- package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.spec.ts +344 -344
- package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.ts +197 -197
- package/src/_modules/bot/_modules/slack-bot/index.ts +12 -12
- package/src/_modules/bot/_modules/teams-bot/_models/teb-platform.types.ts +9 -9
- package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.spec.ts +345 -345
- package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.ts +197 -197
- package/src/_modules/bot/_modules/teams-bot/index.ts +11 -11
- package/src/_modules/bot/_services/bot-commands.control-service.spec.ts +116 -116
- package/src/_modules/bot/_services/bot-commands.control-service.ts +158 -158
- package/src/_modules/bot/_services/bot-io.control-service.spec.ts +285 -285
- package/src/_modules/bot/_services/bot-io.control-service.ts +329 -329
- package/src/_modules/bot/_services/bot-main.control-service.spec.ts +208 -208
- package/src/_modules/bot/_services/bot-main.control-service.ts +489 -489
- package/src/_modules/bot/_services/bot-messaging-provider.service-base.spec.ts +349 -349
- package/src/_modules/bot/_services/bot-messaging-provider.service-base.ts +158 -158
- package/src/_modules/bot/_services/bot-routines.control-service.spec.ts +111 -111
- package/src/_modules/bot/_services/bot-routines.control-service.ts +78 -78
- package/src/_modules/bot/index.ts +37 -37
- package/src/_modules/custom-data/custom-data.controller.spec.ts +49 -49
- package/src/_modules/custom-data/custom-data.controller.ts +67 -67
- package/src/_modules/custom-data/custom-data.data-service.spec.ts +54 -54
- package/src/_modules/custom-data/custom-data.data-service.ts +21 -21
- package/src/_modules/custom-data/get-custom-data-routing-module.util.spec.ts +28 -28
- package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +24 -24
- package/src/_modules/custom-data/index.ts +9 -9
- package/src/_modules/data-readers/_collections/dynts-sqlite-reader.util.spec.ts +176 -176
- package/src/_modules/data-readers/_collections/dynts-sqlite-reader.util.ts +203 -203
- package/src/_modules/data-readers/_models/interfaces/dynts-sqlite-reader.interface.ts +33 -33
- package/src/_modules/data-readers/index.ts +11 -11
- package/src/_modules/defaults/_collections/default-endpoints.util.ts +487 -487
- package/src/_modules/defaults/_models/default-user.data-model.ts +72 -72
- package/src/_modules/defaults/_services/default-auth.service.spec.ts +269 -269
- package/src/_modules/defaults/_services/default-auth.service.ts +177 -177
- package/src/_modules/defaults/_services/default-socket-events.service.spec.ts +42 -42
- package/src/_modules/defaults/_services/default-socket-events.service.ts +61 -61
- package/src/_modules/defaults/_services/default-user.data-service.spec.ts +187 -187
- package/src/_modules/defaults/_services/default-user.data-service.ts +98 -98
- package/src/_modules/defaults/index.ts +17 -17
- package/src/_modules/discord-assistant/_collections/dias-global-settings.const.ts +19 -19
- package/src/_modules/discord-assistant/_collections/dias.util.spec.ts +366 -366
- package/src/_modules/discord-assistant/_collections/dias.util.ts +132 -132
- package/src/_modules/discord-assistant/_models/dias-global-settings.interface.ts +19 -19
- package/src/_modules/discord-assistant/_models/dias-knowledge.data-model.ts +52 -52
- package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +177 -177
- package/src/_modules/discord-assistant/_services/dias-io.control-service.spec.ts +108 -108
- package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +69 -69
- package/src/_modules/discord-assistant/_services/dias-main.control-service.spec.ts +22 -22
- package/src/_modules/discord-assistant/_services/dias-main.control-service.ts +27 -27
- package/src/_modules/discord-assistant/_services/dias.service-base.spec.ts +195 -195
- package/src/_modules/discord-assistant/_services/dias.service-base.ts +76 -76
- package/src/_modules/discord-assistant/index.ts +38 -38
- package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.spec.ts +34 -34
- package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.ts +11 -11
- package/src/_modules/discord-assistant-voiced/index.ts +36 -36
- package/src/_modules/discord-bot/_collections/dibo-default-commands.const.ts +16 -16
- package/src/_modules/discord-bot/_collections/dibo-global-settings.conts.ts +55 -55
- package/src/_modules/discord-bot/_collections/dibo-operations.util.spec.ts +214 -214
- package/src/_modules/discord-bot/_collections/dibo-operations.util.ts +387 -387
- package/src/_modules/discord-bot/_models/dibo-command.interface.ts +12 -12
- package/src/_modules/discord-bot/_models/dibo-global-settings.interface.ts +98 -98
- package/src/_modules/discord-bot/_models/dibo-last-mention-date.inteface.ts +7 -7
- package/src/_modules/discord-bot/_models/dibo-last-message-date.interface.ts +6 -6
- package/src/_modules/discord-bot/_services/dibo-commands.control-service.spec.ts +154 -154
- package/src/_modules/discord-bot/_services/dibo-commands.control-service.ts +153 -153
- package/src/_modules/discord-bot/_services/dibo-io.control-service.spec.ts +264 -264
- package/src/_modules/discord-bot/_services/dibo-io.control-service.ts +306 -306
- package/src/_modules/discord-bot/_services/dibo-main.control-service.spec.ts +408 -408
- package/src/_modules/discord-bot/_services/dibo-main.control-service.ts +487 -487
- package/src/_modules/discord-bot/_services/dibo-routines.control-service.spec.ts +105 -105
- package/src/_modules/discord-bot/_services/dibo-routines.control-service.ts +97 -97
- package/src/_modules/discord-bot/index.ts +36 -36
- package/src/_modules/local-vector-search/_enums/lvs-search-mode.enum.ts +35 -35
- package/src/_modules/local-vector-search/_models/data-models/lvs-vector-persist.data-model.ts +60 -60
- package/src/_modules/local-vector-search/_models/lvs-search-result.interface.ts +17 -17
- package/src/_modules/local-vector-search/_services/lvs-bm25.util.spec.ts +159 -159
- package/src/_modules/local-vector-search/_services/lvs-bm25.util.ts +206 -206
- package/src/_modules/local-vector-search/_services/lvs-doc-chunk-data.service.spec.ts +418 -418
- package/src/_modules/local-vector-search/_services/lvs-doc-chunk-data.service.ts +276 -276
- package/src/_modules/local-vector-search/_services/lvs-local-vector-search.data-service.spec.ts +480 -480
- package/src/_modules/local-vector-search/_services/lvs-local-vector-search.data-service.ts +416 -416
- package/src/_modules/local-vector-search/_services/lvs-persistent-vector-pool.control-service.spec.ts +198 -198
- package/src/_modules/local-vector-search/_services/lvs-persistent-vector-pool.control-service.ts +150 -150
- package/src/_modules/local-vector-search/_services/lvs-vector-persist.data-service.spec.ts +167 -167
- package/src/_modules/local-vector-search/_services/lvs-vector-persist.data-service.ts +108 -108
- package/src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.spec.ts +393 -393
- package/src/_modules/local-vector-search/_services/lvs-vector-pool.control-service.ts +220 -220
- package/src/_modules/local-vector-search/index.ts +16 -16
- package/src/_modules/logs/_models/file-log-entry.interface.ts +13 -13
- package/src/_modules/logs/_models/file-log-read-result.interface.ts +37 -37
- package/src/_modules/logs/file-log.service.spec.ts +341 -341
- package/src/_modules/logs/file-log.service.ts +466 -466
- package/src/_modules/logs/file-logs.controller.spec.ts +245 -245
- package/src/_modules/logs/file-logs.controller.ts +165 -165
- package/src/_modules/logs/get-file-logs-routing-module.util.ts +51 -51
- package/src/_modules/logs/get-logs-routing-module.util.ts +36 -36
- package/src/_modules/logs/index.ts +11 -11
- package/src/_modules/logs/log-buffer.service.ts +101 -101
- package/src/_modules/logs/logs.controller.ts +109 -109
- package/src/_modules/logs/logs.service.ts +100 -100
- package/src/_modules/mcp/_models/interfaces/dynts-mcp.interface.ts +111 -111
- package/src/_modules/mcp/_services/dynts-mcp-server.service-base.spec.ts +151 -151
- package/src/_modules/mcp/_services/dynts-mcp-server.service-base.ts +125 -125
- package/src/_modules/mcp/_services/dynts-mcp.adapter.ts +168 -168
- package/src/_modules/mcp/index.ts +13 -13
- package/src/_modules/messaging/README.md +354 -354
- package/src/_modules/messaging/_collections/get-messaging-routing-module.util.ts +26 -26
- package/src/_modules/messaging/_collections/msg-global-settings.const.ts +22 -22
- package/src/_modules/messaging/_collections/msg.util.spec.ts +226 -226
- package/src/_modules/messaging/_collections/msg.util.ts +83 -83
- package/src/_modules/messaging/_models/msg-global-settings.interface.ts +37 -37
- package/src/_modules/messaging/_services/msg-conversation.data-service.ts +146 -146
- package/src/_modules/messaging/_services/msg-events.service.spec.ts +219 -219
- package/src/_modules/messaging/_services/msg-events.service.ts +267 -267
- package/src/_modules/messaging/_services/msg-integration.control-service.ts +179 -179
- package/src/_modules/messaging/_services/msg-main.control-service.spec.ts +147 -147
- package/src/_modules/messaging/_services/msg-main.control-service.ts +571 -571
- package/src/_modules/messaging/_services/msg-message.data-service.ts +129 -129
- package/src/_modules/messaging/_services/msg.controller.spec.ts +201 -201
- package/src/_modules/messaging/_services/msg.controller.ts +370 -370
- package/src/_modules/messaging/index.ts +30 -30
- package/src/_modules/mock/app-extended-server.mock.ts +201 -201
- package/src/_modules/mock/app-integration-test.mock.ts +51 -51
- package/src/_modules/mock/app-params.mock.spec.ts +21 -21
- package/src/_modules/mock/app-params.mock.ts +9 -9
- package/src/_modules/mock/app-server.mock.ts +188 -188
- package/src/_modules/mock/auth-service.mock.spec.ts +47 -47
- package/src/_modules/mock/auth-service.mock.ts +28 -28
- package/src/_modules/mock/controller.mock.spec.ts +26 -26
- package/src/_modules/mock/controller.mock.ts +16 -16
- package/src/_modules/mock/data-model.mock.spec.ts +111 -111
- package/src/_modules/mock/data-model.mock.ts +82 -82
- package/src/_modules/mock/email-service-collection.mock.spec.ts +24 -24
- package/src/_modules/mock/email-service-collection.mock.ts +15 -15
- package/src/_modules/mock/email-service.mock.spec.ts +17 -17
- package/src/_modules/mock/email-service.mock.ts +20 -20
- package/src/_modules/mock/email-template.mock.html +14 -14
- package/src/_modules/mock/endpoint.mock.ts +91 -91
- package/src/_modules/mock/socket-client.mock.spec.ts +40 -40
- package/src/_modules/mock/socket-client.mock.ts +45 -45
- package/src/_modules/mock/socket-server.mock.spec.ts +44 -44
- package/src/_modules/mock/socket-server.mock.ts +46 -46
- package/src/_modules/oauth2/_routes/oauth2.controller.spec.ts +107 -107
- package/src/_modules/oauth2/_routes/oauth2.controller.ts +98 -98
- package/src/_modules/oauth2/_services/oauth2.auth-service.spec.ts +254 -254
- package/src/_modules/oauth2/_services/oauth2.auth-service.ts +232 -232
- package/src/_modules/oauth2/_services/oauth2.control-service.spec.ts +585 -585
- package/src/_modules/oauth2/_services/oauth2.control-service.ts +653 -653
- package/src/_modules/oauth2/index.ts +17 -17
- package/src/_modules/rate-limit/_models/rate-limit-config.interface.ts +69 -69
- package/src/_modules/rate-limit/_models/rate-limit-policy.interface.ts +16 -16
- package/src/_modules/rate-limit/index.ts +3 -3
- package/src/_modules/rate-limit/rate-limit.middleware.spec.ts +264 -264
- package/src/_modules/rate-limit/rate-limit.middleware.ts +343 -343
- package/src/_modules/scoped-config/_enums/dynts-scoped-config-level.enum.ts +22 -22
- package/src/_modules/scoped-config/_models/data-models/dynts-scoped-config.data-model.ts +82 -82
- package/src/_modules/scoped-config/_models/interfaces/dynts-scoped-config.interface.ts +107 -107
- package/src/_modules/scoped-config/_services/dynts-scoped-config.control-service.spec.ts +312 -312
- package/src/_modules/scoped-config/_services/dynts-scoped-config.control-service.ts +311 -311
- package/src/_modules/scoped-config/_services/dynts-scoped-config.data-service.spec.ts +123 -123
- package/src/_modules/scoped-config/_services/dynts-scoped-config.data-service.ts +108 -108
- package/src/_modules/scoped-config/index.ts +17 -17
- package/src/_modules/server/errors/errors.control-service.spec.ts +246 -238
- package/src/_modules/server/errors/errors.control-service.ts +100 -85
- package/src/_modules/server/errors/errors.controller.spec.ts +249 -241
- package/src/_modules/server/errors/errors.controller.ts +489 -431
- package/src/_modules/server/errors/errors.data-service.spec.ts +480 -361
- package/src/_modules/server/errors/errors.data-service.ts +816 -722
- package/src/_modules/server/index.ts +30 -30
- package/src/_modules/server/server-status/server-status-snapshot.control-service.spec.ts +70 -70
- package/src/_modules/server/server-status/server-status-snapshot.control-service.ts +17 -17
- package/src/_modules/server/server-status/server-status-snapshot.data-service.spec.ts +77 -77
- package/src/_modules/server/server-status/server-status-snapshot.data-service.ts +37 -37
- package/src/_modules/server/server-status/server-status.control-service.spec.ts +584 -576
- package/src/_modules/server/server-status/server-status.control-service.ts +396 -396
- package/src/_modules/server/server-status/server-status.controller.spec.ts +248 -240
- package/src/_modules/server/server-status/server-status.controller.ts +253 -253
- package/src/_modules/socket/_enums/socket-security.enum.ts +11 -11
- package/src/_modules/socket/_models/socket-client-service-params.control-model.spec.ts +32 -32
- package/src/_modules/socket/_models/socket-client-service-params.control-model.ts +22 -22
- package/src/_modules/socket/_models/socket-presence.control-model.spec.ts +164 -164
- package/src/_modules/socket/_models/socket-presence.control-model.ts +210 -210
- package/src/_modules/socket/_models/socket-server-service-params.control-model.spec.ts +46 -46
- package/src/_modules/socket/_models/socket-server-service-params.control-model.ts +22 -22
- package/src/_modules/socket/_services/socket-client.service.spec.ts +15 -15
- package/src/_modules/socket/_services/socket-client.service.ts +260 -260
- package/src/_modules/socket/_services/socket-server.service.spec.ts +11 -11
- package/src/_modules/socket/_services/socket-server.service.ts +1068 -1068
- package/src/_modules/socket/app-extended.integration.spec.ts +85 -85
- package/src/_modules/socket/app-extended.server.ts +630 -630
- package/src/_modules/socket/index.ts +42 -42
- package/src/_modules/test/get-test-routing-module.util.spec.ts +28 -28
- package/src/_modules/test/get-test-routing-module.util.ts +23 -23
- package/src/_modules/test/index.ts +11 -11
- package/src/_modules/test/test.controller.spec.ts +72 -72
- package/src/_modules/test/test.controller.ts +115 -115
- package/src/_modules/usage/get-usage-routing-module.util.ts +22 -22
- package/src/_modules/usage/index.ts +15 -15
- package/src/_modules/usage/usage.controller.spec.ts +81 -81
- package/src/_modules/usage/usage.controller.ts +126 -126
- package/src/_modules/usage/usage.data-service.spec.ts +332 -332
- package/src/_modules/usage/usage.data-service.ts +185 -185
- package/src/_services/base/api.service-base.spec.ts +125 -125
- package/src/_services/base/api.service-base.ts +74 -74
- package/src/_services/base/archive-data.service.spec.ts +196 -196
- package/src/_services/base/archive-data.service.ts +216 -216
- package/src/_services/base/data.service.spec.ts +674 -674
- package/src/_services/base/data.service.ts +2719 -2719
- package/src/_services/base/db.service.spec.ts +73 -73
- package/src/_services/base/db.service.ts +1575 -1575
- package/src/_services/base/singleton.service-base.spec.ts +28 -28
- package/src/_services/base/singleton.service-base.ts +24 -24
- package/src/_services/base/singleton.service.spec.ts +114 -114
- package/src/_services/base/singleton.service.ts +38 -38
- package/src/_services/core/api.service.spec.ts +140 -140
- package/src/_services/core/api.service.ts +607 -607
- package/src/_services/core/auth.service.spec.ts +159 -159
- package/src/_services/core/auth.service.ts +174 -174
- package/src/_services/core/email.service.spec.ts +85 -85
- package/src/_services/core/email.service.ts +742 -742
- package/src/_services/core/global.service.spec.ts +292 -292
- package/src/_services/core/global.service.ts +475 -475
- package/src/_services/core/memory-guard.service.spec.ts +165 -165
- package/src/_services/core/memory-guard.service.ts +281 -281
- package/src/_services/core/service-collection.service.spec.ts +46 -46
- package/src/_services/core/service-collection.service.ts +6 -6
- package/src/_services/route/controller.service.spec.ts +53 -53
- package/src/_services/route/controller.service.ts +148 -148
- package/src/_services/route/routing-module.service.spec.ts +98 -98
- package/src/_services/route/routing-module.service.ts +330 -330
- package/src/_services/server/app.server.ts +1747 -1747
- package/src/_services/shared.static-service.spec.ts +99 -99
- package/src/_services/shared.static-service.ts +78 -78
- package/src/index.ts +96 -96
- package/tsconfig.app.json +12 -12
- package/tsconfig.json +42 -42
- package/.dynamo/logs/cicd-pipeline/output.log +0 -2771
- package/.dynamo/logs/cicd-pipeline/status.json +0 -94
|
@@ -1,1324 +1,1324 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DyNTS_App = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Mongoose = require("mongoose");
|
|
6
|
-
const Express = require("express");
|
|
7
|
-
/* import Mongoose from 'mongoose';
|
|
8
|
-
import Express from 'express'; */
|
|
9
|
-
const BodyParser = tslib_1.__importStar(require("body-parser"));
|
|
10
|
-
const FileSystem = tslib_1.__importStar(require("fs"));
|
|
11
|
-
const Https = tslib_1.__importStar(require("https"));
|
|
12
|
-
const Path = tslib_1.__importStar(require("path"));
|
|
13
|
-
/* import { version } from '../../../package.json'; */
|
|
14
|
-
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
15
|
-
const default_fallback_cache_max_age_const_1 = require("../../_collections/default-fallback-cache-max-age.const");
|
|
16
|
-
const default_not_found_page_const_1 = require("../../_collections/default-not-found-page.const");
|
|
17
|
-
const global_settings_const_1 = require("../../_collections/global-settings.const");
|
|
18
|
-
const mongo_reconnect_guard_util_1 = require("../../_collections/mongo-reconnect-guard.util");
|
|
19
|
-
const route_security_enum_1 = require("../../_enums/route-security.enum");
|
|
20
|
-
const app_system_controls_control_model_1 = require("../../_models/control-models/app-system-controls.control-model");
|
|
21
|
-
const http_settings_control_model_1 = require("../../_models/control-models/http-settings.control-model");
|
|
22
|
-
const singleton_service_1 = require("../base/singleton.service");
|
|
23
|
-
const global_service_1 = require("../core/global.service");
|
|
24
|
-
const memory_guard_service_1 = require("../core/memory-guard.service");
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* function MyDecorator(config: any) {
|
|
28
|
-
return function (target: Function) {
|
|
29
|
-
// attach metadata or modify target
|
|
30
|
-
target.prototype.myMeta = config;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@MyDecorator({ role: 'admin' })
|
|
35
|
-
class User {
|
|
36
|
-
printRole() {
|
|
37
|
-
console.log((this as any).myMeta.role); // → "admin"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* This will be the MAIN service of our server project,
|
|
44
|
-
* follow the types and type instructions while setting up your project
|
|
45
|
-
*
|
|
46
|
-
* In this service, there are abstract functions that you will need to implement,
|
|
47
|
-
* where you need to set up the main params for your application.
|
|
48
|
-
*
|
|
49
|
-
* (after the example, you can find the list of services you can/should setup)
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* export class App extends DyNTS_AppExtended {
|
|
53
|
-
*
|
|
54
|
-
* ...
|
|
55
|
-
*
|
|
56
|
-
* // Setting up App params, and preparing project global settings
|
|
57
|
-
* setupAppParams(): void {
|
|
58
|
-
* this.params = new DyNTS_AppParams({
|
|
59
|
-
* name: 'Warbots Server',
|
|
60
|
-
* title: warbotsTitleLog,
|
|
61
|
-
* version: version,
|
|
62
|
-
* dbName: 'warbots',
|
|
63
|
-
* });
|
|
64
|
-
*
|
|
65
|
-
* // dynamoNTS_GlobalSettings.logRequestsContent = false;
|
|
66
|
-
* }
|
|
67
|
-
*
|
|
68
|
-
* ...
|
|
69
|
-
*
|
|
70
|
-
* // Setting up DBServices
|
|
71
|
-
* setGlobalServiceCollection(): void {
|
|
72
|
-
* DyNTS_GlobalService.setServices({
|
|
73
|
-
* authService: AuthService.getInstance(),
|
|
74
|
-
* emailServiceCollection: EmailServiceCollectionService.getInstance(),
|
|
75
|
-
* dbModels: [
|
|
76
|
-
* userModelParams,
|
|
77
|
-
* userDataModelParams,
|
|
78
|
-
* userOptionsModelParams,
|
|
79
|
-
* userStatisticsModelParams,
|
|
80
|
-
* userAchievementsModelParams,
|
|
81
|
-
* userNotificationsModelParams,
|
|
82
|
-
*
|
|
83
|
-
* matchStatisticsModelParams,
|
|
84
|
-
* matchDataModelParams,
|
|
85
|
-
|
|
86
|
-
* DyFM_usageSession_dataParams,
|
|
87
|
-
* DyFM_customData_dataParams,
|
|
88
|
-
* ]
|
|
89
|
-
* });
|
|
90
|
-
* }
|
|
91
|
-
*
|
|
92
|
-
* ...
|
|
93
|
-
*
|
|
94
|
-
* // Setting up Routes
|
|
95
|
-
* setupRoutingModules(): void {
|
|
96
|
-
* this.httpPort = env.port;
|
|
97
|
-
|
|
98
|
-
* this.routingModules = [
|
|
99
|
-
* new DyNTS_RoutingModule({
|
|
100
|
-
* route: '/user',
|
|
101
|
-
* controllers: [
|
|
102
|
-
* UserController.getInstance(),
|
|
103
|
-
* UserDataController.getInstance(),
|
|
104
|
-
* UserOptionsController.getInstance(),
|
|
105
|
-
* UserStatisticsController.getInstance(),
|
|
106
|
-
* UserAchievementsController.getInstance(),
|
|
107
|
-
* UserNotificationsController.getInstance()
|
|
108
|
-
* ]
|
|
109
|
-
* }),
|
|
110
|
-
* new DyNTS_RoutingModule({
|
|
111
|
-
* route: '/match',
|
|
112
|
-
* controllers: [
|
|
113
|
-
* MatchController.getInstance(),
|
|
114
|
-
* MatchDistributionController.getInstance(),
|
|
115
|
-
* MatchStatisticsController.getInstance(),
|
|
116
|
-
* ]
|
|
117
|
-
* }),
|
|
118
|
-
* new DyNTS_RoutingModule({
|
|
119
|
-
* route: '/server',
|
|
120
|
-
* controllers: [
|
|
121
|
-
* ServerController.getInstance(),
|
|
122
|
-
* ]
|
|
123
|
-
* }),
|
|
124
|
-
|
|
125
|
-
* getTestRoutingModule(),
|
|
126
|
-
* getUsageRoutingModule()
|
|
127
|
-
* ];
|
|
128
|
-
* }
|
|
129
|
-
* }
|
|
130
|
-
*
|
|
131
|
-
* //
|
|
132
|
-
* // The Services available
|
|
133
|
-
* //
|
|
134
|
-
* // Authentication Service
|
|
135
|
-
* // A commonly used basic service,
|
|
136
|
-
* // which is necessary fur certain functions (such as registering call issuers)
|
|
137
|
-
* //
|
|
138
|
-
* // This will handle Authentication Token checking/refreshing,
|
|
139
|
-
* // checking issuer's identifier and routeParams,
|
|
140
|
-
* // handling JWT Token, or maybe with OAuth2 or other commonly used security procedures
|
|
141
|
-
* //
|
|
142
|
-
* // You can create one with this Dynamo Object:
|
|
143
|
-
* //
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* // follow the instructions on the abstract class (DyNTS_AuthService)
|
|
147
|
-
* export class AuthService extends DyNTS_AuthService {}
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* //
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* This will be the MAIN service of our server project,
|
|
155
|
-
* follow the types and type instructions while setting up your project
|
|
156
|
-
*
|
|
157
|
-
* In this service, there are abstract functions that you will need to implement,
|
|
158
|
-
* where you need to set up the main params for your application.
|
|
159
|
-
*
|
|
160
|
-
* (after the example, you can find the list of services you can/should setup)
|
|
161
|
-
*
|
|
162
|
-
* You need to setup the following functions:
|
|
163
|
-
* ```ts
|
|
164
|
-
* // this is where you set up the main params for your application
|
|
165
|
-
* getAppParams(): DyNTS_AppParams
|
|
166
|
-
*
|
|
167
|
-
* // this is where you connect your main services
|
|
168
|
-
* getGlobalServiceSettings(): DyNTS_GlobalService_Settings
|
|
169
|
-
*
|
|
170
|
-
* // this is where you set up your ports
|
|
171
|
-
* getPorts(): DyNTS_PortSettings
|
|
172
|
-
*
|
|
173
|
-
* // this is where you set up your routes
|
|
174
|
-
* getRoutingModules(): DyNTS_RoutingModule[]
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* ```
|
|
179
|
-
* optionally you can setup the following functions:
|
|
180
|
-
* ```ts
|
|
181
|
-
* // this is where you set up your certifications
|
|
182
|
-
* getCertificationSettings(): DyNTS_CertificationSettings
|
|
183
|
-
*
|
|
184
|
-
* // this is where you set up additional root services
|
|
185
|
-
* getRootServices(): DyNTS_SingletonService[]
|
|
186
|
-
*
|
|
187
|
-
* // this is where you set up your initial db entries
|
|
188
|
-
* createEntries(): void
|
|
189
|
-
*
|
|
190
|
-
* // this is where you can define post setup processes
|
|
191
|
-
* postProcess(): void
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
*/
|
|
198
|
-
class DyNTS_App extends singleton_service_1.DyNTS_SingletonService {
|
|
199
|
-
systemControls = new app_system_controls_control_model_1.DyNTS_AppSystemControls();
|
|
200
|
-
get started() {
|
|
201
|
-
return this.systemControls.app.started;
|
|
202
|
-
}
|
|
203
|
-
get superStarted() {
|
|
204
|
-
return this.systemControls.app.started;
|
|
205
|
-
}
|
|
206
|
-
constructErrors = [];
|
|
207
|
-
/* removed since cant use version from package.json
|
|
208
|
-
private readonly _ntsVersion: string = 'v01.07.18';
|
|
209
|
-
protected get ntsVersion(): string {
|
|
210
|
-
return this._ntsVersion;
|
|
211
|
-
} */
|
|
212
|
-
get serverName() {
|
|
213
|
-
return this.params.name;
|
|
214
|
-
}
|
|
215
|
-
_params;
|
|
216
|
-
get params() {
|
|
217
|
-
return this._params;
|
|
218
|
-
}
|
|
219
|
-
mongoose = Mongoose;
|
|
220
|
-
_security;
|
|
221
|
-
get security() {
|
|
222
|
-
return this._security;
|
|
223
|
-
}
|
|
224
|
-
_portSettings = new http_settings_control_model_1.DyNTS_Http_Settings();
|
|
225
|
-
get portSettings() {
|
|
226
|
-
return this._portSettings;
|
|
227
|
-
}
|
|
228
|
-
_cert;
|
|
229
|
-
get cert() {
|
|
230
|
-
return this._cert;
|
|
231
|
-
}
|
|
232
|
-
openExpress;
|
|
233
|
-
secureExpress;
|
|
234
|
-
httpsServer;
|
|
235
|
-
httpServer;
|
|
236
|
-
globalService;
|
|
237
|
-
_rootServices = [];
|
|
238
|
-
_routingModules = [];
|
|
239
|
-
defaultReadyTimeout = 30 * fsm_dynamo_1.second;
|
|
240
|
-
defaultErrorUserMsg = `We encountered an unhandled Server Error, ` +
|
|
241
|
-
`\nplease contact the responsible development team.` +
|
|
242
|
-
`\n(Internal Server error)`;
|
|
243
|
-
get logSetup() {
|
|
244
|
-
return global_settings_const_1.DyNTS_global_settings.log_settings.setup;
|
|
245
|
-
}
|
|
246
|
-
get deepLog() {
|
|
247
|
-
return global_settings_const_1.DyNTS_global_settings.log_settings.deep;
|
|
248
|
-
}
|
|
249
|
-
get fnLogs() {
|
|
250
|
-
return global_settings_const_1.DyNTS_global_settings.log_settings.functions;
|
|
251
|
-
}
|
|
252
|
-
debugLog = global_settings_const_1.DyNTS_global_settings.log_settings.server_debug;
|
|
253
|
-
constructor( /* extended?: boolean */) {
|
|
254
|
-
super();
|
|
255
|
-
/* dotenv.config() */
|
|
256
|
-
process.on('unhandledRejection', (reason_theError, p_passWhatIsThis_maybeThePromise) => {
|
|
257
|
-
if (reason_theError instanceof fsm_dynamo_1.DyFM_Error) {
|
|
258
|
-
reason_theError.logSimple('Unhandled Rejection');
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
fsm_dynamo_1.DyFM_Log.H_error('Unhandled Rejection:', p_passWhatIsThis_maybeThePromise?.toString(), '\n Rejection reason:', reason_theError?.stack?.split('at')?.[0],
|
|
262
|
-
/* '\n ErrorCode:', (reason as any)?.code, */
|
|
263
|
-
'\n\n Stack:', reason_theError?.stack?.replaceAll?.('\n at', '\n at'));
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(new fsm_dynamo_1.DyFM_Error({
|
|
267
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-BASE-UR`,
|
|
268
|
-
message: `Unhandled Rejection!: "${reason_theError?.stack?.split('at')?.[0]}"`,
|
|
269
|
-
userMessage: this.defaultErrorUserMsg,
|
|
270
|
-
addECToUserMsg: true,
|
|
271
|
-
error: reason_theError,
|
|
272
|
-
additionalContent: {
|
|
273
|
-
reason: reason_theError,
|
|
274
|
-
rejectedPromise: p_passWhatIsThis_maybeThePromise,
|
|
275
|
-
},
|
|
276
|
-
systemVersion: global_settings_const_1.DyNTS_global_settings.systemVersion,
|
|
277
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
278
|
-
}));
|
|
279
|
-
}
|
|
280
|
-
catch (error) {
|
|
281
|
-
fsm_dynamo_1.DyFM_Log.error('globalErrorHandler (MULTILEVEL) ERROR:', error);
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
this.asyncConstruct( /* extended */).catch((error) => {
|
|
285
|
-
if (error instanceof fsm_dynamo_1.DyFM_Error) {
|
|
286
|
-
if (error.additionalContent?.constructErrors?.length) {
|
|
287
|
-
error.additionalContent.constructErrors.forEach((errorItem) => {
|
|
288
|
-
fsm_dynamo_1.DyFM_Error.logSimple('(constructor asyncConstruct.catch) error:', errorItem);
|
|
289
|
-
/* if (errorItem instanceof DyFM_Error) {
|
|
290
|
-
errorItem.logSimple(`(constructor asyncConstruct.catch) error:\n`);
|
|
291
|
-
} else {
|
|
292
|
-
DyFM_Log.H_warn(
|
|
293
|
-
'(constructor asyncConstruct.catch) additional error content:\n',
|
|
294
|
-
errorItem
|
|
295
|
-
);
|
|
296
|
-
} */
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
fsm_dynamo_1.DyFM_Log.H_warn('(constructor asyncConstruct.catch) additional error content:\n', error?.additionalContent);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
fsm_dynamo_1.DyFM_Error.logSimple('(constructor asyncConstruct.catch) error:', error);
|
|
304
|
-
/* if (
|
|
305
|
-
!DyNTS_global_settings.log_settings.highDetailedLogs &&
|
|
306
|
-
(error instanceof DyFM_Error)
|
|
307
|
-
) {
|
|
308
|
-
error.logSimple(
|
|
309
|
-
`Application: "${this.params?.name}" start failed. (constructor asyncConstruct.catch)` +
|
|
310
|
-
'\n all error messages (from this stack):\n\n"' +
|
|
311
|
-
error._messages.join('"\n\n"') + '"\n\n'
|
|
312
|
-
);
|
|
313
|
-
} else if (error instanceof DyFM_Error) {
|
|
314
|
-
DyFM_Log.H_error(
|
|
315
|
-
`Application: "${this.params?.name}" start failed. (constructor asyncConstruct.catch)`,
|
|
316
|
-
`\n ERROR:`, error
|
|
317
|
-
);
|
|
318
|
-
} */
|
|
319
|
-
const message = error?.additionalContent?.constructErrors?.flatMap((errorItem) => {
|
|
320
|
-
return errorItem?._messages ?? [];
|
|
321
|
-
})?.join?.('\n') ??
|
|
322
|
-
error?.errors?.flatMap((errorItem) => errorItem?._messages ?? [errorItem?.message])?.join?.('\n') ??
|
|
323
|
-
error?.message ??
|
|
324
|
-
'UNKNOWN';
|
|
325
|
-
fsm_dynamo_1.DyFM_Log.testError('Application start failed:\n', message);
|
|
326
|
-
process.exit(1);
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
async asyncConstruct(extended) {
|
|
330
|
-
if (this.fnLogs && this.deepLog)
|
|
331
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. asyncConstruct');
|
|
332
|
-
try {
|
|
333
|
-
this.systemControls.app.init = true;
|
|
334
|
-
this._params = this.getAppParams();
|
|
335
|
-
fsm_dynamo_1.DyFM_Log.log(`\n\n\n\n\n\n\n\n\n\n` +
|
|
336
|
-
`Starting ${this._params?.name}... ` +
|
|
337
|
-
/* `v${version}` + */
|
|
338
|
-
`\n\n\n\n\n\n\n\n\n\n`);
|
|
339
|
-
if (!this._params) {
|
|
340
|
-
throw new Error('getAppParams() must return a DyNTS_AppParams object!');
|
|
341
|
-
}
|
|
342
|
-
if (this.params.systemShortCodeName) {
|
|
343
|
-
global_settings_const_1.DyNTS_global_settings.systemShortCodeName = this.params.systemShortCodeName;
|
|
344
|
-
}
|
|
345
|
-
if (this.params.systemName) {
|
|
346
|
-
global_settings_const_1.DyNTS_global_settings.systemName = this.params.systemName;
|
|
347
|
-
fsm_dynamo_1.DyFM_error_defaults.issuerSystem = this.params.systemName;
|
|
348
|
-
}
|
|
349
|
-
if (this.params.version) {
|
|
350
|
-
global_settings_const_1.DyNTS_global_settings.systemVersion = this.params.version;
|
|
351
|
-
fsm_dynamo_1.DyFM_error_defaults.systemVersion = this.params.version;
|
|
352
|
-
}
|
|
353
|
-
process.stdout.write(String.fromCharCode(27) + ']0;' +
|
|
354
|
-
this._params?.name +
|
|
355
|
-
String.fromCharCode(7));
|
|
356
|
-
fsm_dynamo_1.DyFM_error_defaults.issuerSystem = this._params.systemName;
|
|
357
|
-
this.overrideDynamoNTSGlobalSettings?.();
|
|
358
|
-
if (global_settings_const_1.DyNTS_global_settings.log_settings.setup) {
|
|
359
|
-
fsm_dynamo_1.DyFM_Log.S_info(`env settings;\n`, {
|
|
360
|
-
systemName: global_settings_const_1.DyNTS_global_settings.systemName,
|
|
361
|
-
systemShortCodeName: global_settings_const_1.DyNTS_global_settings.systemShortCodeName,
|
|
362
|
-
systemVersion: global_settings_const_1.DyNTS_global_settings.systemVersion,
|
|
363
|
-
environment: global_settings_const_1.DyNTS_global_settings.env_settings.environment,
|
|
364
|
-
/* log_settings: DyNTS_global_settings.log_settings,
|
|
365
|
-
env_settings: DyNTS_global_settings.env_settings, */
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
this.globalService = global_service_1.DyNTS_GlobalService.getInstance();
|
|
369
|
-
await global_service_1.DyNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
370
|
-
global_service_1.DyNTS_GlobalService.setParams(this.params);
|
|
371
|
-
if (this.getPortSettings) {
|
|
372
|
-
this._portSettings = this.getPortSettings();
|
|
373
|
-
}
|
|
374
|
-
if (this.getCertificationSettings) {
|
|
375
|
-
this._cert = this.getCertificationSettings();
|
|
376
|
-
}
|
|
377
|
-
if (this.getApiBasePath) {
|
|
378
|
-
global_settings_const_1.DyNTS_global_settings.baseUrl = this.getApiBasePath();
|
|
379
|
-
}
|
|
380
|
-
if (this.getRoutingModules) {
|
|
381
|
-
this._routingModules = this.getRoutingModules();
|
|
382
|
-
// ezt egyelőre csak tesztelem, nem kerül be
|
|
383
|
-
/* if (
|
|
384
|
-
!DyNTS_global_settings.dontCreateDefaultRoute &&
|
|
385
|
-
!this._routingModules.some((routingModule: DyNTS_RoutingModule): boolean => routingModule.route === '/*')
|
|
386
|
-
) {
|
|
387
|
-
this._routingModules.push(
|
|
388
|
-
DyNTS_getStarRoute()
|
|
389
|
-
);
|
|
390
|
-
} */
|
|
391
|
-
}
|
|
392
|
-
if (this._params.dbUri) {
|
|
393
|
-
await this.startDB();
|
|
394
|
-
// createEntries csak akkor fut, ha a DB tényleg fel-jött.
|
|
395
|
-
// Ha a startDB jelezte a hibát, de továbbment, akkor a started flag false marad,
|
|
396
|
-
// és nem próbálunk meg írni egy nem létező kapcsolatra.
|
|
397
|
-
if (this.createEntries && this.systemControls.mongoose.started) {
|
|
398
|
-
await this.createEntries();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
fsm_dynamo_1.DyFM_Log.log(`\nNo database connection created.`);
|
|
403
|
-
}
|
|
404
|
-
if (this._routingModules?.length) {
|
|
405
|
-
if (this.logSetup)
|
|
406
|
-
fsm_dynamo_1.DyFM_Log.log('\nsetting up express routes...');
|
|
407
|
-
this.setSecurity();
|
|
408
|
-
await this.initExpresses();
|
|
409
|
-
await this.startExpresses();
|
|
410
|
-
if (this._security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
411
|
-
await this.mountOpenRoutes();
|
|
412
|
-
}
|
|
413
|
-
if (this._security !== route_security_enum_1.DyNTS_RouteSecurity.open && this._cert) {
|
|
414
|
-
await this.mountSecureRoutes();
|
|
415
|
-
}
|
|
416
|
-
// Generikus, auth-agnosztikus extension-point: custom middleware az API
|
|
417
|
-
// route-ok UTÁN, de a SPA static catch-all (mountStaticClient) ELŐTT.
|
|
418
|
-
await this.mountCustomMiddleware();
|
|
419
|
-
await this.mountStaticClient();
|
|
420
|
-
if (this.logSetup) {
|
|
421
|
-
fsm_dynamo_1.DyFM_Log.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
fsm_dynamo_1.DyFM_Log.warn(`\nNo routes mounted!`);
|
|
426
|
-
}
|
|
427
|
-
if (this.getRootServices) {
|
|
428
|
-
this._rootServices = await this.getRootServices();
|
|
429
|
-
}
|
|
430
|
-
if (this.postProcess) {
|
|
431
|
-
await this.postProcess().catch((error) => {
|
|
432
|
-
fsm_dynamo_1.DyFM_Error.logSimple(`"${this._params.name}" postProcess failed:`, error);
|
|
433
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(error);
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
// FR-193 — bedrock OOM korai-figyelmeztetés: feltelepítjük a heap-watchdogot, ha
|
|
437
|
-
// engedélyezve (DyNTS_global_settings.memoryGuard.enabled, default true). Biztonságos:
|
|
438
|
-
// a guard egy könnyű setInterval, ami SOHA nem dob; csak near-OOM küszöböknél hagy
|
|
439
|
-
// tartós nyomot az error-sinkbe, mielőtt a fatal heap-OOM megölné a process-t.
|
|
440
|
-
try {
|
|
441
|
-
if (global_settings_const_1.DyNTS_global_settings.memoryGuard?.enabled) {
|
|
442
|
-
memory_guard_service_1.DyNTS_MemoryGuard.getInstance().install();
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
catch (memoryGuardError) {
|
|
446
|
-
fsm_dynamo_1.DyFM_Log.warn('[DyNTS_MemoryGuard] auto-install skipped (non-fatal):', memoryGuardError);
|
|
447
|
-
}
|
|
448
|
-
if (!extended) {
|
|
449
|
-
await this.ready();
|
|
450
|
-
if (this.params.title) {
|
|
451
|
-
fsm_dynamo_1.DyFM_Log.success(this.params.title);
|
|
452
|
-
}
|
|
453
|
-
fsm_dynamo_1.DyFM_Log.info(`Version: ${this.params.version}`);
|
|
454
|
-
/* DyFM_Log.info(`NTS Version: ${this.ntsVersion}`); */
|
|
455
|
-
fsm_dynamo_1.DyFM_Log.H_success(`${this.params.name} started successfully.`);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
catch (error) {
|
|
459
|
-
this.constructErrors.push(error);
|
|
460
|
-
if (this.deepLog) {
|
|
461
|
-
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
462
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed (in asyncConstruct (highDetailedLog)). `, `\n\n construct ERRORS:`, this.constructErrors, '\n\nlast error:', error);
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed (in asyncConstruct). `, `\n\n construct ERRORS:`, this.getSimplifiedConstructErrors(), '\n\nlast error:', error instanceof fsm_dynamo_1.DyFM_Error ? error.getErrorSimplified() : error);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
469
|
-
...this._getDefaultErrorSettings('asyncConstruct', error),
|
|
470
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-001`,
|
|
471
|
-
additionalContent: {
|
|
472
|
-
constructErrors: this.constructErrors,
|
|
473
|
-
systemControls: this.systemControls,
|
|
474
|
-
systemReadies: {
|
|
475
|
-
app: this.systemControls.app.getIsReady(),
|
|
476
|
-
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
477
|
-
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
478
|
-
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
async ready(timeout = this.defaultReadyTimeout) {
|
|
485
|
-
try {
|
|
486
|
-
if (this.fnLogs)
|
|
487
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. ready');
|
|
488
|
-
await fsm_dynamo_1.DyFM_Async.delay(100);
|
|
489
|
-
let ready = false;
|
|
490
|
-
const start = +new Date();
|
|
491
|
-
if (this.constructErrors.length) {
|
|
492
|
-
if (this.deepLog) {
|
|
493
|
-
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
494
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 1)`, `\n construct ERRORS:`, this.constructErrors);
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 1)`, `\n construct ERRORS:`, this.getSimplifiedConstructErrors());
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
501
|
-
...this._getDefaultErrorSettings('ready', new Error(`"${this._params.name}" start failed.`)),
|
|
502
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R01`,
|
|
503
|
-
additionalContent: this.constructErrors.length === 1 ?
|
|
504
|
-
{ error: this.constructErrors[0] } :
|
|
505
|
-
{ errors: this.constructErrors },
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
while (!ready && +new Date() - start < timeout) {
|
|
509
|
-
if (this.systemControls.app.init) {
|
|
510
|
-
ready = (this.systemControls.mongoose.getIsReady() &&
|
|
511
|
-
this.systemControls.httpServer.getIsReady() &&
|
|
512
|
-
this.systemControls.httpsServer.getIsReady());
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
fsm_dynamo_1.DyFM_Log.error(`"${this._params.name}" APP NOT INITIALIZED while trying to get ready.`);
|
|
516
|
-
}
|
|
517
|
-
if (!ready) {
|
|
518
|
-
await fsm_dynamo_1.DyFM_Async.wait(100);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
if (timeout < +new Date() - start) {
|
|
522
|
-
if (this.deepLog) {
|
|
523
|
-
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
524
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; TIMEOUT check)`, `\n construct ERRORS:`, this.constructErrors);
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; TIMEOUT check)`, `\n construct ERRORS:`, this.getSimplifiedConstructErrors());
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
531
|
-
...this._getDefaultErrorSettings('ready', new Error(`"${this._params.name}" start failed. TIMEOUT`)),
|
|
532
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R02`,
|
|
533
|
-
additionalContent: {
|
|
534
|
-
constructErrors: this.constructErrors,
|
|
535
|
-
systemControls: this.systemControls,
|
|
536
|
-
systemReadies: {
|
|
537
|
-
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
538
|
-
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
539
|
-
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
if (this.constructErrors.length) {
|
|
545
|
-
if (this.deepLog) {
|
|
546
|
-
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
547
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 2)`, `\n construct ERRORS:`, this.constructErrors);
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 2)`, `\n construct ERRORS:`, this.getSimplifiedConstructErrors());
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
554
|
-
...this._getDefaultErrorSettings('ready', new Error(`"${this._params.name}" start failed.`)),
|
|
555
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R03`,
|
|
556
|
-
additionalContent: this.constructErrors,
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
if (ready) {
|
|
560
|
-
this.systemControls.app.started = true;
|
|
561
|
-
if (this.fnLogs && this.deepLog)
|
|
562
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. ready: return');
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
this.systemControls.app.started = false;
|
|
566
|
-
let msg = `"${this._params.name}" start failed. UNKNOWN`;
|
|
567
|
-
if (this.systemControls.mongoose.init && !this.systemControls.mongoose.started) {
|
|
568
|
-
msg += `\nMongoose start failed.`;
|
|
569
|
-
}
|
|
570
|
-
if (this.systemControls.httpServer.init && !this.systemControls.httpServer.started) {
|
|
571
|
-
msg += `\nHTTP Server start failed.`;
|
|
572
|
-
}
|
|
573
|
-
if (this.systemControls.httpsServer.init && !this.systemControls.httpsServer.started) {
|
|
574
|
-
msg += `\nHTTPS Server start failed.`;
|
|
575
|
-
}
|
|
576
|
-
fsm_dynamo_1.DyFM_Log.error(msg, this.constructErrors);
|
|
577
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
578
|
-
...this._getDefaultErrorSettings('ready', new Error(msg)),
|
|
579
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R04`,
|
|
580
|
-
additionalContent: {
|
|
581
|
-
constructErrors: this.constructErrors,
|
|
582
|
-
systemControls: this.systemControls,
|
|
583
|
-
systemReadies: {
|
|
584
|
-
app: this.systemControls.app.getIsReady(),
|
|
585
|
-
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
586
|
-
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
587
|
-
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
error: this.constructErrors?.[0] ?? new Error(),
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
catch (error) {
|
|
594
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
595
|
-
...this._getDefaultErrorSettings('ready', error),
|
|
596
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-READY0`,
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
getSimplifiedConstructErrors() {
|
|
601
|
-
return this.constructErrors.map((error) => {
|
|
602
|
-
if (error instanceof fsm_dynamo_1.DyFM_Error) {
|
|
603
|
-
return error.getErrorSimplified();
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
return error;
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
async stop(dontLog) {
|
|
611
|
-
try {
|
|
612
|
-
fsm_dynamo_1.DyFM_Log.info('\nstopping server...\n');
|
|
613
|
-
await this.ready();
|
|
614
|
-
if (this.started) {
|
|
615
|
-
if (this.systemControls.mongoose.init) {
|
|
616
|
-
fsm_dynamo_1.DyFM_Log.info(`\nstopping Mongoose....`);
|
|
617
|
-
let tryCount = 0;
|
|
618
|
-
while (!this.systemControls.mongoose.started &&
|
|
619
|
-
!this.constructErrors.length &&
|
|
620
|
-
tryCount++ < 10) {
|
|
621
|
-
fsm_dynamo_1.DyFM_Log.warn(`Mongoose not even started yet....`);
|
|
622
|
-
await fsm_dynamo_1.DyFM_Async.wait(fsm_dynamo_1.second);
|
|
623
|
-
}
|
|
624
|
-
this.systemControls.mongoose.started = false;
|
|
625
|
-
if (this.mongoose) {
|
|
626
|
-
await fsm_dynamo_1.DyFM_Array.asyncForEach(Object.keys(this.mongoose.models), async (modelName) => {
|
|
627
|
-
this.mongoose.deleteModel(modelName);
|
|
628
|
-
});
|
|
629
|
-
const disconnect = new Promise((resolve) => {
|
|
630
|
-
this.mongoose.connection.on('disconnecting', () => {
|
|
631
|
-
resolve();
|
|
632
|
-
});
|
|
633
|
-
});
|
|
634
|
-
await this.mongoose.disconnect();
|
|
635
|
-
await this.mongoose.connection.close();
|
|
636
|
-
await disconnect;
|
|
637
|
-
this.mongoose.connection.removeAllListeners();
|
|
638
|
-
while (this.mongoose.connection.readyState !== 0 &&
|
|
639
|
-
!this.constructErrors.length) {
|
|
640
|
-
fsm_dynamo_1.DyFM_Log.warn(`\nMongoose still not disconnected....`);
|
|
641
|
-
await fsm_dynamo_1.DyFM_Async.wait(fsm_dynamo_1.second);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
fsm_dynamo_1.DyFM_Log.error(`\nMongoose not found.`);
|
|
646
|
-
}
|
|
647
|
-
this.systemControls.mongoose.init = false;
|
|
648
|
-
}
|
|
649
|
-
if (this.systemControls.httpServer.init) {
|
|
650
|
-
this.systemControls.httpServer.started = false;
|
|
651
|
-
if (this.httpServer) {
|
|
652
|
-
await new Promise((resolve) => {
|
|
653
|
-
this.httpServer.close(resolve);
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
fsm_dynamo_1.DyFM_Log.error(`\nHTTP Server not found.`);
|
|
658
|
-
}
|
|
659
|
-
this.systemControls.httpServer.init = false;
|
|
660
|
-
}
|
|
661
|
-
if (this.systemControls.httpsServer.init) {
|
|
662
|
-
this.systemControls.httpsServer.started = false;
|
|
663
|
-
if (this.httpsServer) {
|
|
664
|
-
await new Promise((resolve) => {
|
|
665
|
-
this.httpsServer.close(resolve);
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
fsm_dynamo_1.DyFM_Log.error(`\nHTTPS Server not found.`);
|
|
670
|
-
}
|
|
671
|
-
this.systemControls.httpsServer.init = false;
|
|
672
|
-
}
|
|
673
|
-
await fsm_dynamo_1.DyFM_Async.wait(fsm_dynamo_1.second);
|
|
674
|
-
if (!dontLog) {
|
|
675
|
-
fsm_dynamo_1.DyFM_Log.H_log(`"${this._params.name}" stopped successfully.`);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
catch (error) {
|
|
680
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
681
|
-
...this._getDefaultErrorSettings('stop', error),
|
|
682
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-STOP0`,
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
*
|
|
688
|
-
*/
|
|
689
|
-
async startDB() {
|
|
690
|
-
if (this.fnLogs && this.deepLog)
|
|
691
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. startDB');
|
|
692
|
-
else if (this.logSetup)
|
|
693
|
-
fsm_dynamo_1.DyFM_Log.log('\nstarting DB connection...');
|
|
694
|
-
if (!this._params.dbUri) {
|
|
695
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
696
|
-
...this._getDefaultErrorSettings('startDB', new Error('DB URI is not set.')),
|
|
697
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
if (!this._params.dbOptions) {
|
|
701
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
702
|
-
...this._getDefaultErrorSettings('startDB', new Error('DB OPTIONS are not set.')),
|
|
703
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
if (this.systemControls.mongoose.init || this.systemControls.mongoose.started) {
|
|
707
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
708
|
-
...this._getDefaultErrorSettings('startDB', new Error('Mongoose is already initialized.')),
|
|
709
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
try {
|
|
713
|
-
await new Promise((resolve, reject) => {
|
|
714
|
-
this.systemControls.mongoose.init = true;
|
|
715
|
-
this.mongoose.connection
|
|
716
|
-
.once('open', () => {
|
|
717
|
-
this.systemControls.mongoose.started = true;
|
|
718
|
-
fsm_dynamo_1.DyFM_Log.success(`\nConnected to MongoDB (${this._params.dbUri})\n`);
|
|
719
|
-
resolve();
|
|
720
|
-
})
|
|
721
|
-
.on('error', (error) => {
|
|
722
|
-
if (!this.systemControls.mongoose.started) {
|
|
723
|
-
// Initial DB-csatlakozás sikertelen:
|
|
724
|
-
// jelezzük a hibát (log + globalErrorHandler), de NEM szakítjuk meg az
|
|
725
|
-
// App startup-ot (nincs constructErrors push, nincs reject).
|
|
726
|
-
// A mongoose.init-et resetteljük, hogy a ready() ne várjon a DB-re.
|
|
727
|
-
// Ha a mongoose később mégis tudna csatlakozni, az 'open' event
|
|
728
|
-
// beállítja a started flag-et, így a runtime DB-műveletek elindulnak.
|
|
729
|
-
this.systemControls.mongoose.init = false;
|
|
730
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
731
|
-
...this._getDefaultErrorSettings('startDB', error),
|
|
732
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB1`,
|
|
733
|
-
message: `Unable to connect to MongoDB server (${this._params.dbUri}), ` +
|
|
734
|
-
`ERROR: ${error}`,
|
|
735
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.serious,
|
|
736
|
-
});
|
|
737
|
-
fsm_dynamo_1.DyFM_Log.H_error(`\nUnable to connect to MongoDB server (${this._params.dbUri}).` +
|
|
738
|
-
`\nServer will continue WITHOUT DB connection.` +
|
|
739
|
-
`\nDB-using endpoints will fail at runtime until connection recovers.`);
|
|
740
|
-
if (this.debugLog)
|
|
741
|
-
fsm_dynamo_1.DyFM_Log.S_error(`\nMongoDB connect ERROR: `, error);
|
|
742
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
743
|
-
resolve();
|
|
744
|
-
}
|
|
745
|
-
else {
|
|
746
|
-
if (this.debugLog)
|
|
747
|
-
fsm_dynamo_1.DyFM_Log.error('\nMongoDB ERROR: ', error);
|
|
748
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
749
|
-
...this._getDefaultErrorSettings('mongoose.connection.on(error)', error),
|
|
750
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB2`,
|
|
751
|
-
message: `MongoDB ERROR: ${error}`,
|
|
752
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
753
|
-
});
|
|
754
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
try {
|
|
758
|
-
this.mongoose.connect(this._params.dbUri, this._params.dbOptions
|
|
759
|
-
/* {
|
|
760
|
-
directConnection: true,
|
|
761
|
-
} */
|
|
762
|
-
);
|
|
763
|
-
}
|
|
764
|
-
catch (error) {
|
|
765
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
766
|
-
...this._getDefaultErrorSettings('startDB', error),
|
|
767
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB3`,
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
catch (error) {
|
|
773
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
774
|
-
...this._getDefaultErrorSettings('startDB', error),
|
|
775
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
// 2026-06-20 — Mongo reconnect-guard. A MongoDB-driver a hostnevet connect-kor EGYSZER
|
|
779
|
-
// resolválja + cache-eli az IP-t; ha a Mongo-konténert recreate-elik (új docker-network IP),
|
|
780
|
-
// a driver a HALOTT IP-n ragad → ECONNREFUSED + buffering-timeout, és a service magától SOHA
|
|
781
|
-
// nem áll vissza. A guard sustained-disconnect (readyState !== 1) esetén — a driver saját
|
|
782
|
-
// grace-e UTÁN — TELJES disconnect()+connect()-et csinál → ÚJ MongoClient → ÚJ DNS-resolve →
|
|
783
|
-
// új IP → reconnect. Best-effort, always-on, healthy connection-t (===1) SOHA nem bánt; csak
|
|
784
|
-
// konténer-IP-frissítés, nem ír adatot. Lásd: mongo-reconnect-guard.util.ts.
|
|
785
|
-
try {
|
|
786
|
-
(0, mongo_reconnect_guard_util_1.startMongoReconnectGuard)({
|
|
787
|
-
getReadyState: () => this.mongoose.connection.readyState,
|
|
788
|
-
reconnect: async () => {
|
|
789
|
-
await this.mongoose.disconnect().catch(() => undefined);
|
|
790
|
-
await this.mongoose.connect(this._params.dbUri, this._params.dbOptions);
|
|
791
|
-
},
|
|
792
|
-
log: (msg) => fsm_dynamo_1.DyFM_Log.warn(msg),
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
catch (guardErr) {
|
|
796
|
-
fsm_dynamo_1.DyFM_Log.warn(`[mongo-reconnect-guard] failed to start (non-fatal): ${guardErr instanceof Error ? guardErr.message : String(guardErr)}`);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
*
|
|
801
|
-
*/
|
|
802
|
-
async initExpresses() {
|
|
803
|
-
if (this.fnLogs && this.deepLog)
|
|
804
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. initExpresses');
|
|
805
|
-
try {
|
|
806
|
-
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
807
|
-
if (this._portSettings.httpPort === undefined || this._portSettings.httpPort === null) {
|
|
808
|
-
let errorMsg = `\nYou have open routes, but httpPort is not set!` +
|
|
809
|
-
`\nThere are ${this._routingModules.filter(m => m.security != route_security_enum_1.DyNTS_RouteSecurity.secure).length} open/both routes` +
|
|
810
|
-
`\nroot security: ${this._security}` +
|
|
811
|
-
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
812
|
-
errorMsg += '\n\nThe routes setted to use open server:';
|
|
813
|
-
this._routingModules.forEach((module) => {
|
|
814
|
-
if (module.security != route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
815
|
-
errorMsg += `\n ${module.route} (security: ${module.security})`;
|
|
816
|
-
errorMsg += `\n subroutes using open sever:`;
|
|
817
|
-
module.endpoints.forEach((endpoint) => {
|
|
818
|
-
if (endpoint.security != route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
819
|
-
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
820
|
-
}
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
});
|
|
824
|
-
const error = new Error(`Open routes cannot be established!\n${errorMsg}`);
|
|
825
|
-
const errorStack = error.stack.split('\n');
|
|
826
|
-
errorStack.splice(1, 2);
|
|
827
|
-
error.stack = errorStack.join('\n');
|
|
828
|
-
fsm_dynamo_1.DyFM_Log.error(errorMsg);
|
|
829
|
-
throw error;
|
|
830
|
-
}
|
|
831
|
-
await this.initOpenExpress();
|
|
832
|
-
}
|
|
833
|
-
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
834
|
-
if (!this._cert || !this._portSettings.httpsPort) {
|
|
835
|
-
let errorMsg = `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
836
|
-
`\nThere are ${this._routingModules.filter(m => m.security && m.security !== route_security_enum_1.DyNTS_RouteSecurity.open).length} secure routes` +
|
|
837
|
-
`\nroot security: ${this._security}` +
|
|
838
|
-
`\nset...` +
|
|
839
|
-
`\n(missing exact howto...)` +
|
|
840
|
-
/* `\n httpsPort and` +
|
|
841
|
-
`\n cert: {` +
|
|
842
|
-
`\n keyPath: FileSystem.PathLike,` +
|
|
843
|
-
`\n certPath: FileSystem.PathLike,` +
|
|
844
|
-
`\n }` + */
|
|
845
|
-
`\nin DynamoBEServer - getRoutingModules() to enable secure routes.`;
|
|
846
|
-
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
847
|
-
this._routingModules.forEach((module) => {
|
|
848
|
-
if (module.security && module.security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
849
|
-
errorMsg += `\n ${module.route} (security: ${module.security})`;
|
|
850
|
-
errorMsg += `\n location: ${module.stackLocation}`;
|
|
851
|
-
errorMsg += `\n subroutes using secure sever:`;
|
|
852
|
-
module.endpoints.forEach((endpoint) => {
|
|
853
|
-
if (endpoint.security && endpoint.security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
854
|
-
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
855
|
-
errorMsg += `\n location: ${endpoint.stackLocation}`;
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
});
|
|
860
|
-
const error = new Error(`Secure routes cannot be established!\n${errorMsg}`);
|
|
861
|
-
const errorStack = error.stack.split('\n');
|
|
862
|
-
errorStack.splice(1, 2);
|
|
863
|
-
error.stack = errorStack.join('\n');
|
|
864
|
-
fsm_dynamo_1.DyFM_Log.error(errorMsg);
|
|
865
|
-
throw error;
|
|
866
|
-
}
|
|
867
|
-
await this.initSecureExpress();
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
catch (error) {
|
|
871
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
872
|
-
...this._getDefaultErrorSettings('initExpresses', error),
|
|
873
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-IE0`,
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
/**
|
|
878
|
-
*
|
|
879
|
-
*/
|
|
880
|
-
async initOpenExpress() {
|
|
881
|
-
if (this.fnLogs)
|
|
882
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. initOpenExpress');
|
|
883
|
-
this.openExpress = Express();
|
|
884
|
-
this.openExpress.set('maxHeaderSize', 10 * fsm_dynamo_1.megabyte); // 1024 * 1024 * 10, // 10MB
|
|
885
|
-
this.openExpress.use(BodyParser.urlencoded(this._portSettings.httpUrlencoded));
|
|
886
|
-
this.openExpress.use(BodyParser.json(this._portSettings.httpJson));
|
|
887
|
-
// FR-041 — CORS allowlist enforcement. No-op if getCorsSettings() is not overridden.
|
|
888
|
-
this.mountCors(this.openExpress);
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
*
|
|
892
|
-
*/
|
|
893
|
-
async initSecureExpress() {
|
|
894
|
-
if (this.fnLogs)
|
|
895
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. initSecureExpress');
|
|
896
|
-
this.secureExpress = Express();
|
|
897
|
-
this.secureExpress.use(BodyParser.urlencoded(this._portSettings.httpsUrlencoded));
|
|
898
|
-
this.secureExpress.use(BodyParser.json(this._portSettings.httpsJson));
|
|
899
|
-
// FR-041 — CORS allowlist enforcement (same as open express).
|
|
900
|
-
this.mountCors(this.secureExpress);
|
|
901
|
-
const options = {
|
|
902
|
-
key: FileSystem.readFileSync(this._cert.keyPath),
|
|
903
|
-
cert: FileSystem.readFileSync(this._cert.certPath),
|
|
904
|
-
maxHeaderSize: 10 * fsm_dynamo_1.megabyte, // 1024 * 1024 * 10, // 10MB
|
|
905
|
-
};
|
|
906
|
-
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
*
|
|
910
|
-
*/
|
|
911
|
-
async startExpresses() {
|
|
912
|
-
if (this.fnLogs && this.deepLog)
|
|
913
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. startExpresses');
|
|
914
|
-
try {
|
|
915
|
-
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
916
|
-
await new Promise((resolve, reject) => {
|
|
917
|
-
this.systemControls.httpsServer.init = true;
|
|
918
|
-
this.httpsServer
|
|
919
|
-
.listen(this._portSettings.httpsPort, this.params.secureHost, this.params.expressBacklog, () => {
|
|
920
|
-
this.systemControls.httpsServer.started = true;
|
|
921
|
-
fsm_dynamo_1.DyFM_Log.success(`\nHTTPS (secure) server is listening on port: ` +
|
|
922
|
-
`${this.params.secureHost}:${this._portSettings.httpsPort}`);
|
|
923
|
-
resolve();
|
|
924
|
-
})
|
|
925
|
-
.on('error', (error) => {
|
|
926
|
-
if (this.debugLog)
|
|
927
|
-
fsm_dynamo_1.DyFM_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
928
|
-
if (!this.systemControls.httpsServer.started) {
|
|
929
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
930
|
-
...this._getDefaultErrorSettings('startExpresses', error),
|
|
931
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE1`,
|
|
932
|
-
message: `HTTPS (secure) start server ERROR`,
|
|
933
|
-
});
|
|
934
|
-
this.constructErrors.push(d_error);
|
|
935
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
936
|
-
reject(d_error);
|
|
937
|
-
}
|
|
938
|
-
else {
|
|
939
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
940
|
-
...this._getDefaultErrorSettings('httpsServer.on(error)', error),
|
|
941
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE2`,
|
|
942
|
-
message: `HTTPS (secure) server ERROR`,
|
|
943
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.serious,
|
|
944
|
-
});
|
|
945
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
946
|
-
}
|
|
947
|
-
})
|
|
948
|
-
.on('uncaughtException', (exception) => {
|
|
949
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
950
|
-
...this._getDefaultErrorSettings('httpsServer.on(uncaughtException)', exception),
|
|
951
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE3`,
|
|
952
|
-
message: `HTTPS (secure) server uncaughtException`,
|
|
953
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
954
|
-
});
|
|
955
|
-
if (this.debugLog)
|
|
956
|
-
fsm_dynamo_1.DyFM_Log.warn(`\nHTTPS (secure) server uncaughtException`, d_error);
|
|
957
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
958
|
-
});
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
962
|
-
this.systemControls.httpServer.init = true;
|
|
963
|
-
await new Promise((resolve, reject) => {
|
|
964
|
-
this.httpServer = this.openExpress
|
|
965
|
-
.listen(this._portSettings.httpPort, this.params.openHost, this.params.expressBacklog, () => {
|
|
966
|
-
this.systemControls.httpServer.started = true;
|
|
967
|
-
const resolvedPort = this.httpServer?.address?.()?.['port'] ?? this._portSettings.httpPort;
|
|
968
|
-
if (this._portSettings.httpPort === 0) {
|
|
969
|
-
fsm_dynamo_1.DyFM_Log.H_warn(`\nHTTP (open) server is using a randomly selected port by the OS: ${resolvedPort}` +
|
|
970
|
-
`\n (httpPort was set to 0 — this is intended for testing only)`);
|
|
971
|
-
}
|
|
972
|
-
fsm_dynamo_1.DyFM_Log.success(`\nHTTP (open) server is listening on port: ` +
|
|
973
|
-
`${this.params.openHost}:${resolvedPort}`);
|
|
974
|
-
resolve();
|
|
975
|
-
})
|
|
976
|
-
.on('error', (error) => {
|
|
977
|
-
if (this.debugLog)
|
|
978
|
-
fsm_dynamo_1.DyFM_Log.error(`\nHTTP (open) server ERROR`, error);
|
|
979
|
-
if (!this.systemControls.httpServer.started) {
|
|
980
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
981
|
-
...this._getDefaultErrorSettings('startExpresses', error),
|
|
982
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE3`,
|
|
983
|
-
message: `HTTP (open) start server ERROR`,
|
|
984
|
-
});
|
|
985
|
-
this.constructErrors.push(d_error);
|
|
986
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
987
|
-
reject(d_error);
|
|
988
|
-
}
|
|
989
|
-
else {
|
|
990
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
991
|
-
...this._getDefaultErrorSettings('httpServer.on(error)', error),
|
|
992
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE4`,
|
|
993
|
-
message: `HTTP (open) server ERROR`,
|
|
994
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.serious,
|
|
995
|
-
});
|
|
996
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
997
|
-
}
|
|
998
|
-
})
|
|
999
|
-
.on('uncaughtException', (exception) => {
|
|
1000
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
1001
|
-
...this._getDefaultErrorSettings('httpServer.on(uncaughtException)', exception),
|
|
1002
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE5`,
|
|
1003
|
-
message: `HTTP (open) server uncaughtException`,
|
|
1004
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
1005
|
-
});
|
|
1006
|
-
if (this.debugLog) {
|
|
1007
|
-
fsm_dynamo_1.DyFM_Log.warn(`\nHTTP (open) server uncaughtException`, d_error);
|
|
1008
|
-
}
|
|
1009
|
-
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
1010
|
-
});
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
catch (error) {
|
|
1015
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
1016
|
-
...this._getDefaultErrorSettings('startExpresses', error),
|
|
1017
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE0`,
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
*
|
|
1023
|
-
*/
|
|
1024
|
-
async expressErrorHandling(error, req, res, next) {
|
|
1025
|
-
try {
|
|
1026
|
-
if (error) {
|
|
1027
|
-
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
1028
|
-
...this._getDefaultErrorSettings('expressErrorHandling', error),
|
|
1029
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-EEH1`,
|
|
1030
|
-
message: `Express ERROR`,
|
|
1031
|
-
additionalContent: {
|
|
1032
|
-
req,
|
|
1033
|
-
res,
|
|
1034
|
-
},
|
|
1035
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.error,
|
|
1036
|
-
});
|
|
1037
|
-
await global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error, req, res);
|
|
1038
|
-
res.send(error);
|
|
1039
|
-
}
|
|
1040
|
-
else {
|
|
1041
|
-
fsm_dynamo_1.DyFM_Log.H_error('WTF??? express error; without error?...' +
|
|
1042
|
-
'\nerr:', error, '\nreq:', req, '\nres:', res);
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
catch (error) {
|
|
1046
|
-
fsm_dynamo_1.DyFM_Log.H_error('MULTILEVEL ERROR (expressErrorHandling)....' +
|
|
1047
|
-
'\n', error);
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
*
|
|
1052
|
-
*/
|
|
1053
|
-
async mountSecureRoutes() {
|
|
1054
|
-
try {
|
|
1055
|
-
if (this.fnLogs && this.deepLog)
|
|
1056
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. mountSecureRoutes');
|
|
1057
|
-
if (!this.secureExpress) {
|
|
1058
|
-
throw new Error('secureExpress was not initialized. ' +
|
|
1059
|
-
'Secure routes require getCertificationSettings and httpsPort, and cert files must exist.' +
|
|
1060
|
-
'\n\nYou need to set security to secure or both in any route and set httpsPort in getPortSettings.' +
|
|
1061
|
-
'\n\nYou need to set cert files in getCertificationSettings.');
|
|
1062
|
-
}
|
|
1063
|
-
this.secureExpress.use((error, req, res, next) => this.expressErrorHandling(error, req, res, next));
|
|
1064
|
-
await fsm_dynamo_1.DyFM_Array.asyncForEach(this._routingModules, async (module) => {
|
|
1065
|
-
if (module.security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
1066
|
-
if (this.logSetup) {
|
|
1067
|
-
fsm_dynamo_1.DyFM_Log.log(`route mount (secure): ${module.route}`);
|
|
1068
|
-
}
|
|
1069
|
-
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
1070
|
-
if (1 < existingRoutes.length) {
|
|
1071
|
-
const error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
1072
|
-
/* const errorStack: string[] = error.stack.split('\n');
|
|
1073
|
-
|
|
1074
|
-
errorStack.splice(1, 4);
|
|
1075
|
-
error.stack = errorStack.join('\n'); */
|
|
1076
|
-
error.stack = module.stackLocation;
|
|
1077
|
-
fsm_dynamo_1.DyFM_Log.S_error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1078
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
1079
|
-
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
1080
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MSR1`,
|
|
1081
|
-
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
this.secureExpress.use(module.route, module.secureRouter);
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
1087
|
-
}
|
|
1088
|
-
catch (error) {
|
|
1089
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
1090
|
-
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
1091
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MSR0`,
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
*
|
|
1097
|
-
*/
|
|
1098
|
-
async mountOpenRoutes() {
|
|
1099
|
-
try {
|
|
1100
|
-
if (this.fnLogs && this.deepLog)
|
|
1101
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. mountOpenRoutes');
|
|
1102
|
-
if (!this.openExpress) {
|
|
1103
|
-
throw new Error('openExpress was not initialized. Open routes require getOpenExpress and httpPort.' +
|
|
1104
|
-
'\n\nYou need to set security to open or both in any route and set httpPort in getPortSettings.');
|
|
1105
|
-
}
|
|
1106
|
-
this.openExpress.use((error, req, res, next) => this.expressErrorHandling(error, req, res, next));
|
|
1107
|
-
await fsm_dynamo_1.DyFM_Array.asyncForEach(this._routingModules, async (module) => {
|
|
1108
|
-
if (module.security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
1109
|
-
if (this.logSetup) {
|
|
1110
|
-
fsm_dynamo_1.DyFM_Log.log(`route mount (open): ${module.route}`);
|
|
1111
|
-
}
|
|
1112
|
-
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
1113
|
-
if (1 < existingRoutes.length) {
|
|
1114
|
-
const error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
1115
|
-
/* const errorStack: string[] = error.stack.split('\n');
|
|
1116
|
-
|
|
1117
|
-
errorStack.splice(1, 4);
|
|
1118
|
-
error.stack = errorStack.join('\n'); */
|
|
1119
|
-
error.stack = module.stackLocation;
|
|
1120
|
-
fsm_dynamo_1.DyFM_Log.S_error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1121
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
1122
|
-
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
1123
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MOR1`,
|
|
1124
|
-
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
this.openExpress.use(module.route, module.openRouter);
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
catch (error) {
|
|
1132
|
-
throw new fsm_dynamo_1.DyFM_Error({
|
|
1133
|
-
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
1134
|
-
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MOR0`,
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* FR-041 — CORS middleware. Echoes a matching `Access-Control-Allow-Origin`
|
|
1140
|
-
* for any request whose Origin header is in `getCorsSettings().allowedOrigins`,
|
|
1141
|
-
* adds the canonical `Access-Control-*` companion headers, and short-circuits
|
|
1142
|
-
* the OPTIONS preflight with a 204.
|
|
1143
|
-
*
|
|
1144
|
-
* No-op when the subclass does NOT override `getCorsSettings()` — preserves
|
|
1145
|
-
* back-compat for apps that have always been same-origin and never needed
|
|
1146
|
-
* CORS (the typical pre-FR-041 case).
|
|
1147
|
-
*
|
|
1148
|
-
* Why hand-rolled instead of the `cors` npm package:
|
|
1149
|
-
* - ~30 lines, zero new dependency.
|
|
1150
|
-
* - Full control over Vary/credentials/preflight semantics.
|
|
1151
|
-
* - Aligns with FDP "no unnecessary deps" philosophy.
|
|
1152
|
-
*/
|
|
1153
|
-
mountCors(express) {
|
|
1154
|
-
const settings = this.getCorsSettings?.();
|
|
1155
|
-
if (!settings) {
|
|
1156
|
-
return;
|
|
1157
|
-
}
|
|
1158
|
-
const allowCreds = settings.allowCredentials !== false;
|
|
1159
|
-
const methods = settings.allowedMethods ?? [
|
|
1160
|
-
'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS',
|
|
1161
|
-
];
|
|
1162
|
-
const headers = settings.allowedHeaders ?? [
|
|
1163
|
-
'Authorization', 'Content-Type', 'X-Admin-Key', 'X-Requested-With',
|
|
1164
|
-
];
|
|
1165
|
-
const exposed = settings.exposedHeaders ?? [
|
|
1166
|
-
'Content-Length', 'Content-Type',
|
|
1167
|
-
];
|
|
1168
|
-
const maxAge = settings.maxAgeSeconds ?? 86400;
|
|
1169
|
-
const isAllowed = (origin) => {
|
|
1170
|
-
if (settings.allowedOrigins === '*')
|
|
1171
|
-
return true;
|
|
1172
|
-
if (typeof settings.allowedOrigins === 'function') {
|
|
1173
|
-
return settings.allowedOrigins(origin);
|
|
1174
|
-
}
|
|
1175
|
-
return settings.allowedOrigins.includes(origin);
|
|
1176
|
-
};
|
|
1177
|
-
express.use((req, res, next) => {
|
|
1178
|
-
const origin = req.headers.origin;
|
|
1179
|
-
if (origin && isAllowed(origin)) {
|
|
1180
|
-
// Echo the matching origin (NOT wildcard) because credentials require it.
|
|
1181
|
-
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
1182
|
-
if (allowCreds) {
|
|
1183
|
-
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
1184
|
-
}
|
|
1185
|
-
res.setHeader('Access-Control-Allow-Methods', methods.join(', '));
|
|
1186
|
-
res.setHeader('Access-Control-Allow-Headers', headers.join(', '));
|
|
1187
|
-
res.setHeader('Access-Control-Expose-Headers', exposed.join(', '));
|
|
1188
|
-
res.setHeader('Access-Control-Max-Age', String(maxAge));
|
|
1189
|
-
res.setHeader('Vary', 'Origin');
|
|
1190
|
-
}
|
|
1191
|
-
if (req.method === 'OPTIONS') {
|
|
1192
|
-
res.status(204).end();
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
next();
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
/**
|
|
1199
|
-
* Generikus, auth-agnosztikus extension-point orchestrator. A `registerCustomMiddleware`
|
|
1200
|
-
* hookot hívja (ha a subclass override-olja) minden AKTÍV Express instance-ra
|
|
1201
|
-
* (open + secure), az API route-ok UTÁN, de a SPA static catch-all (`app.get('*')`)
|
|
1202
|
-
* ELŐTT — ez az EGYETLEN korrekt pont egy sub-path middleware-hez (pl. reverse-proxy),
|
|
1203
|
-
* mert a catch-all minden utána mountolt route-ot elnyel. No-op ha nincs override (back-compat).
|
|
1204
|
-
*/
|
|
1205
|
-
async mountCustomMiddleware() {
|
|
1206
|
-
if (!this.registerCustomMiddleware) {
|
|
1207
|
-
return;
|
|
1208
|
-
}
|
|
1209
|
-
if (this.openExpress) {
|
|
1210
|
-
await this.registerCustomMiddleware(this.openExpress, route_security_enum_1.DyNTS_RouteSecurity.open);
|
|
1211
|
-
}
|
|
1212
|
-
if (this.secureExpress) {
|
|
1213
|
-
await this.registerCustomMiddleware(this.secureExpress, route_security_enum_1.DyNTS_RouteSecurity.secure);
|
|
1214
|
-
}
|
|
1215
|
-
if (this.logSetup) {
|
|
1216
|
-
fsm_dynamo_1.DyFM_Log.log('\nCustom middleware registered (pre-static).');
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* Ha getStaticClientSettings() visszaad beállításokat, a client static fájlok a '/' alatt
|
|
1221
|
-
* lesznek kiszolgálva (API route-ok után). SPA fallback opcionális (fallbackPath).
|
|
1222
|
-
* Asset cache (assetCacheMaxAge, assetCacheImmutable) és fallback cache (fallbackCacheMaxAge)
|
|
1223
|
-
* opcionálisak; ha nincs megadva fallbackCacheMaxAge, DyNTS_defaultFallbackCacheMaxAge (0) marad.
|
|
1224
|
-
*/
|
|
1225
|
-
async mountStaticClient() {
|
|
1226
|
-
const settings = this.getStaticClientSettings?.();
|
|
1227
|
-
if (!settings) {
|
|
1228
|
-
return;
|
|
1229
|
-
}
|
|
1230
|
-
const absoluteRoot = Path.isAbsolute(settings.root)
|
|
1231
|
-
? settings.root
|
|
1232
|
-
: Path.resolve(process.cwd(), settings.root);
|
|
1233
|
-
const hasAssetCache = settings.assetCacheMaxAge !== undefined || settings.assetCacheImmutable === true;
|
|
1234
|
-
const staticOptions = hasAssetCache && settings.assetCacheMaxAge !== undefined
|
|
1235
|
-
? {
|
|
1236
|
-
setHeaders: (res) => {
|
|
1237
|
-
const maxAge = settings.assetCacheMaxAge;
|
|
1238
|
-
const immutable = settings.assetCacheImmutable === true ? ', immutable' : '';
|
|
1239
|
-
res.setHeader('Cache-Control', `max-age=${maxAge}${immutable}`);
|
|
1240
|
-
},
|
|
1241
|
-
}
|
|
1242
|
-
: undefined;
|
|
1243
|
-
const staticMiddleware = staticOptions
|
|
1244
|
-
? Express.static(absoluteRoot, staticOptions)
|
|
1245
|
-
: Express.static(absoluteRoot);
|
|
1246
|
-
const fallbackMaxAge = settings.fallbackCacheMaxAge ?? default_fallback_cache_max_age_const_1.DyNTS_defaultFallbackCacheMaxAge;
|
|
1247
|
-
if (this.openExpress) {
|
|
1248
|
-
this.openExpress.use('/', staticMiddleware);
|
|
1249
|
-
if (settings.fallbackPath) {
|
|
1250
|
-
this.openExpress.get('*', (req, res) => {
|
|
1251
|
-
res.setHeader('Cache-Control', `max-age=${fallbackMaxAge}`);
|
|
1252
|
-
res.sendFile(settings.fallbackPath, { root: absoluteRoot });
|
|
1253
|
-
});
|
|
1254
|
-
}
|
|
1255
|
-
else {
|
|
1256
|
-
this.openExpress.get('*', (req, res) => {
|
|
1257
|
-
res.status(404).type('html').send(default_not_found_page_const_1.DyNTS_defaultNotFoundPageHtml);
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
if (this.secureExpress) {
|
|
1262
|
-
this.secureExpress.use('/', staticMiddleware);
|
|
1263
|
-
if (settings.fallbackPath) {
|
|
1264
|
-
this.secureExpress.get('*', (req, res) => {
|
|
1265
|
-
res.setHeader('Cache-Control', `max-age=${fallbackMaxAge}`);
|
|
1266
|
-
res.sendFile(settings.fallbackPath, { root: absoluteRoot });
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
else {
|
|
1270
|
-
this.secureExpress.get('*', (req, res) => {
|
|
1271
|
-
res.status(404).type('html').send(default_not_found_page_const_1.DyNTS_defaultNotFoundPageHtml);
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
if (this.logSetup) {
|
|
1276
|
-
fsm_dynamo_1.DyFM_Log.log(`\nStatic client mounted at / (root: ${absoluteRoot})`);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
*
|
|
1281
|
-
*/
|
|
1282
|
-
setSecurity() {
|
|
1283
|
-
if (this.fnLogs && this.deepLog)
|
|
1284
|
-
fsm_dynamo_1.DyFM_Log.log('\nfn:. setSecurity');
|
|
1285
|
-
this._routingModules.forEach((module) => {
|
|
1286
|
-
if (!module.security) {
|
|
1287
|
-
fsm_dynamo_1.DyFM_Log.warn(`RoutingModule security is not set for ${module.route}\n`);
|
|
1288
|
-
}
|
|
1289
|
-
else if (!this._security) {
|
|
1290
|
-
this._security = module.security;
|
|
1291
|
-
}
|
|
1292
|
-
else if (this._security !== module.security) {
|
|
1293
|
-
this._security = route_security_enum_1.DyNTS_RouteSecurity.both;
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
if (!this._security) {
|
|
1297
|
-
let msg = `Could not set security for the server! (${this.security})`;
|
|
1298
|
-
msg += '\n RoutingModules:';
|
|
1299
|
-
this._routingModules.forEach((module) => {
|
|
1300
|
-
msg += `\n ${module.route} (security: ${module.security})`;
|
|
1301
|
-
});
|
|
1302
|
-
if (this._routingModules.length === 0) {
|
|
1303
|
-
msg += '\n - no RoutingModule found -\n';
|
|
1304
|
-
}
|
|
1305
|
-
fsm_dynamo_1.DyFM_Log.warn(msg);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
_getDefaultErrorSettings(fnName, error) {
|
|
1309
|
-
return {
|
|
1310
|
-
status: error?.___status ?? 500,
|
|
1311
|
-
message: error?.message ??
|
|
1312
|
-
error?._message ??
|
|
1313
|
-
`${fnName} was UNSUCCESSFUL (NTS)`,
|
|
1314
|
-
userMessage: error?.__userMessage ?? this.defaultErrorUserMsg,
|
|
1315
|
-
addECToUserMsg: !error?.__userMessage,
|
|
1316
|
-
issuerService: `${this?.constructor?.name}-DyNTS_App`,
|
|
1317
|
-
level: fsm_dynamo_1.DyFM_ErrorLevel.fatal,
|
|
1318
|
-
error: error,
|
|
1319
|
-
systemVersion: global_settings_const_1.DyNTS_global_settings.systemVersion,
|
|
1320
|
-
};
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
exports.DyNTS_App = DyNTS_App;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DyNTS_App = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Mongoose = require("mongoose");
|
|
6
|
+
const Express = require("express");
|
|
7
|
+
/* import Mongoose from 'mongoose';
|
|
8
|
+
import Express from 'express'; */
|
|
9
|
+
const BodyParser = tslib_1.__importStar(require("body-parser"));
|
|
10
|
+
const FileSystem = tslib_1.__importStar(require("fs"));
|
|
11
|
+
const Https = tslib_1.__importStar(require("https"));
|
|
12
|
+
const Path = tslib_1.__importStar(require("path"));
|
|
13
|
+
/* import { version } from '../../../package.json'; */
|
|
14
|
+
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
15
|
+
const default_fallback_cache_max_age_const_1 = require("../../_collections/default-fallback-cache-max-age.const");
|
|
16
|
+
const default_not_found_page_const_1 = require("../../_collections/default-not-found-page.const");
|
|
17
|
+
const global_settings_const_1 = require("../../_collections/global-settings.const");
|
|
18
|
+
const mongo_reconnect_guard_util_1 = require("../../_collections/mongo-reconnect-guard.util");
|
|
19
|
+
const route_security_enum_1 = require("../../_enums/route-security.enum");
|
|
20
|
+
const app_system_controls_control_model_1 = require("../../_models/control-models/app-system-controls.control-model");
|
|
21
|
+
const http_settings_control_model_1 = require("../../_models/control-models/http-settings.control-model");
|
|
22
|
+
const singleton_service_1 = require("../base/singleton.service");
|
|
23
|
+
const global_service_1 = require("../core/global.service");
|
|
24
|
+
const memory_guard_service_1 = require("../core/memory-guard.service");
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* function MyDecorator(config: any) {
|
|
28
|
+
return function (target: Function) {
|
|
29
|
+
// attach metadata or modify target
|
|
30
|
+
target.prototype.myMeta = config;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@MyDecorator({ role: 'admin' })
|
|
35
|
+
class User {
|
|
36
|
+
printRole() {
|
|
37
|
+
console.log((this as any).myMeta.role); // → "admin"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* This will be the MAIN service of our server project,
|
|
44
|
+
* follow the types and type instructions while setting up your project
|
|
45
|
+
*
|
|
46
|
+
* In this service, there are abstract functions that you will need to implement,
|
|
47
|
+
* where you need to set up the main params for your application.
|
|
48
|
+
*
|
|
49
|
+
* (after the example, you can find the list of services you can/should setup)
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* export class App extends DyNTS_AppExtended {
|
|
53
|
+
*
|
|
54
|
+
* ...
|
|
55
|
+
*
|
|
56
|
+
* // Setting up App params, and preparing project global settings
|
|
57
|
+
* setupAppParams(): void {
|
|
58
|
+
* this.params = new DyNTS_AppParams({
|
|
59
|
+
* name: 'Warbots Server',
|
|
60
|
+
* title: warbotsTitleLog,
|
|
61
|
+
* version: version,
|
|
62
|
+
* dbName: 'warbots',
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // dynamoNTS_GlobalSettings.logRequestsContent = false;
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* ...
|
|
69
|
+
*
|
|
70
|
+
* // Setting up DBServices
|
|
71
|
+
* setGlobalServiceCollection(): void {
|
|
72
|
+
* DyNTS_GlobalService.setServices({
|
|
73
|
+
* authService: AuthService.getInstance(),
|
|
74
|
+
* emailServiceCollection: EmailServiceCollectionService.getInstance(),
|
|
75
|
+
* dbModels: [
|
|
76
|
+
* userModelParams,
|
|
77
|
+
* userDataModelParams,
|
|
78
|
+
* userOptionsModelParams,
|
|
79
|
+
* userStatisticsModelParams,
|
|
80
|
+
* userAchievementsModelParams,
|
|
81
|
+
* userNotificationsModelParams,
|
|
82
|
+
*
|
|
83
|
+
* matchStatisticsModelParams,
|
|
84
|
+
* matchDataModelParams,
|
|
85
|
+
|
|
86
|
+
* DyFM_usageSession_dataParams,
|
|
87
|
+
* DyFM_customData_dataParams,
|
|
88
|
+
* ]
|
|
89
|
+
* });
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* ...
|
|
93
|
+
*
|
|
94
|
+
* // Setting up Routes
|
|
95
|
+
* setupRoutingModules(): void {
|
|
96
|
+
* this.httpPort = env.port;
|
|
97
|
+
|
|
98
|
+
* this.routingModules = [
|
|
99
|
+
* new DyNTS_RoutingModule({
|
|
100
|
+
* route: '/user',
|
|
101
|
+
* controllers: [
|
|
102
|
+
* UserController.getInstance(),
|
|
103
|
+
* UserDataController.getInstance(),
|
|
104
|
+
* UserOptionsController.getInstance(),
|
|
105
|
+
* UserStatisticsController.getInstance(),
|
|
106
|
+
* UserAchievementsController.getInstance(),
|
|
107
|
+
* UserNotificationsController.getInstance()
|
|
108
|
+
* ]
|
|
109
|
+
* }),
|
|
110
|
+
* new DyNTS_RoutingModule({
|
|
111
|
+
* route: '/match',
|
|
112
|
+
* controllers: [
|
|
113
|
+
* MatchController.getInstance(),
|
|
114
|
+
* MatchDistributionController.getInstance(),
|
|
115
|
+
* MatchStatisticsController.getInstance(),
|
|
116
|
+
* ]
|
|
117
|
+
* }),
|
|
118
|
+
* new DyNTS_RoutingModule({
|
|
119
|
+
* route: '/server',
|
|
120
|
+
* controllers: [
|
|
121
|
+
* ServerController.getInstance(),
|
|
122
|
+
* ]
|
|
123
|
+
* }),
|
|
124
|
+
|
|
125
|
+
* getTestRoutingModule(),
|
|
126
|
+
* getUsageRoutingModule()
|
|
127
|
+
* ];
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* //
|
|
132
|
+
* // The Services available
|
|
133
|
+
* //
|
|
134
|
+
* // Authentication Service
|
|
135
|
+
* // A commonly used basic service,
|
|
136
|
+
* // which is necessary fur certain functions (such as registering call issuers)
|
|
137
|
+
* //
|
|
138
|
+
* // This will handle Authentication Token checking/refreshing,
|
|
139
|
+
* // checking issuer's identifier and routeParams,
|
|
140
|
+
* // handling JWT Token, or maybe with OAuth2 or other commonly used security procedures
|
|
141
|
+
* //
|
|
142
|
+
* // You can create one with this Dynamo Object:
|
|
143
|
+
* //
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* // follow the instructions on the abstract class (DyNTS_AuthService)
|
|
147
|
+
* export class AuthService extends DyNTS_AuthService {}
|
|
148
|
+
*
|
|
149
|
+
*
|
|
150
|
+
*
|
|
151
|
+
* //
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* This will be the MAIN service of our server project,
|
|
155
|
+
* follow the types and type instructions while setting up your project
|
|
156
|
+
*
|
|
157
|
+
* In this service, there are abstract functions that you will need to implement,
|
|
158
|
+
* where you need to set up the main params for your application.
|
|
159
|
+
*
|
|
160
|
+
* (after the example, you can find the list of services you can/should setup)
|
|
161
|
+
*
|
|
162
|
+
* You need to setup the following functions:
|
|
163
|
+
* ```ts
|
|
164
|
+
* // this is where you set up the main params for your application
|
|
165
|
+
* getAppParams(): DyNTS_AppParams
|
|
166
|
+
*
|
|
167
|
+
* // this is where you connect your main services
|
|
168
|
+
* getGlobalServiceSettings(): DyNTS_GlobalService_Settings
|
|
169
|
+
*
|
|
170
|
+
* // this is where you set up your ports
|
|
171
|
+
* getPorts(): DyNTS_PortSettings
|
|
172
|
+
*
|
|
173
|
+
* // this is where you set up your routes
|
|
174
|
+
* getRoutingModules(): DyNTS_RoutingModule[]
|
|
175
|
+
*
|
|
176
|
+
*
|
|
177
|
+
*
|
|
178
|
+
* ```
|
|
179
|
+
* optionally you can setup the following functions:
|
|
180
|
+
* ```ts
|
|
181
|
+
* // this is where you set up your certifications
|
|
182
|
+
* getCertificationSettings(): DyNTS_CertificationSettings
|
|
183
|
+
*
|
|
184
|
+
* // this is where you set up additional root services
|
|
185
|
+
* getRootServices(): DyNTS_SingletonService[]
|
|
186
|
+
*
|
|
187
|
+
* // this is where you set up your initial db entries
|
|
188
|
+
* createEntries(): void
|
|
189
|
+
*
|
|
190
|
+
* // this is where you can define post setup processes
|
|
191
|
+
* postProcess(): void
|
|
192
|
+
*
|
|
193
|
+
*
|
|
194
|
+
*
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
*/
|
|
198
|
+
class DyNTS_App extends singleton_service_1.DyNTS_SingletonService {
|
|
199
|
+
systemControls = new app_system_controls_control_model_1.DyNTS_AppSystemControls();
|
|
200
|
+
get started() {
|
|
201
|
+
return this.systemControls.app.started;
|
|
202
|
+
}
|
|
203
|
+
get superStarted() {
|
|
204
|
+
return this.systemControls.app.started;
|
|
205
|
+
}
|
|
206
|
+
constructErrors = [];
|
|
207
|
+
/* removed since cant use version from package.json
|
|
208
|
+
private readonly _ntsVersion: string = 'v01.07.18';
|
|
209
|
+
protected get ntsVersion(): string {
|
|
210
|
+
return this._ntsVersion;
|
|
211
|
+
} */
|
|
212
|
+
get serverName() {
|
|
213
|
+
return this.params.name;
|
|
214
|
+
}
|
|
215
|
+
_params;
|
|
216
|
+
get params() {
|
|
217
|
+
return this._params;
|
|
218
|
+
}
|
|
219
|
+
mongoose = Mongoose;
|
|
220
|
+
_security;
|
|
221
|
+
get security() {
|
|
222
|
+
return this._security;
|
|
223
|
+
}
|
|
224
|
+
_portSettings = new http_settings_control_model_1.DyNTS_Http_Settings();
|
|
225
|
+
get portSettings() {
|
|
226
|
+
return this._portSettings;
|
|
227
|
+
}
|
|
228
|
+
_cert;
|
|
229
|
+
get cert() {
|
|
230
|
+
return this._cert;
|
|
231
|
+
}
|
|
232
|
+
openExpress;
|
|
233
|
+
secureExpress;
|
|
234
|
+
httpsServer;
|
|
235
|
+
httpServer;
|
|
236
|
+
globalService;
|
|
237
|
+
_rootServices = [];
|
|
238
|
+
_routingModules = [];
|
|
239
|
+
defaultReadyTimeout = 30 * fsm_dynamo_1.second;
|
|
240
|
+
defaultErrorUserMsg = `We encountered an unhandled Server Error, ` +
|
|
241
|
+
`\nplease contact the responsible development team.` +
|
|
242
|
+
`\n(Internal Server error)`;
|
|
243
|
+
get logSetup() {
|
|
244
|
+
return global_settings_const_1.DyNTS_global_settings.log_settings.setup;
|
|
245
|
+
}
|
|
246
|
+
get deepLog() {
|
|
247
|
+
return global_settings_const_1.DyNTS_global_settings.log_settings.deep;
|
|
248
|
+
}
|
|
249
|
+
get fnLogs() {
|
|
250
|
+
return global_settings_const_1.DyNTS_global_settings.log_settings.functions;
|
|
251
|
+
}
|
|
252
|
+
debugLog = global_settings_const_1.DyNTS_global_settings.log_settings.server_debug;
|
|
253
|
+
constructor( /* extended?: boolean */) {
|
|
254
|
+
super();
|
|
255
|
+
/* dotenv.config() */
|
|
256
|
+
process.on('unhandledRejection', (reason_theError, p_passWhatIsThis_maybeThePromise) => {
|
|
257
|
+
if (reason_theError instanceof fsm_dynamo_1.DyFM_Error) {
|
|
258
|
+
reason_theError.logSimple('Unhandled Rejection');
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
fsm_dynamo_1.DyFM_Log.H_error('Unhandled Rejection:', p_passWhatIsThis_maybeThePromise?.toString(), '\n Rejection reason:', reason_theError?.stack?.split('at')?.[0],
|
|
262
|
+
/* '\n ErrorCode:', (reason as any)?.code, */
|
|
263
|
+
'\n\n Stack:', reason_theError?.stack?.replaceAll?.('\n at', '\n at'));
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(new fsm_dynamo_1.DyFM_Error({
|
|
267
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-BASE-UR`,
|
|
268
|
+
message: `Unhandled Rejection!: "${reason_theError?.stack?.split('at')?.[0]}"`,
|
|
269
|
+
userMessage: this.defaultErrorUserMsg,
|
|
270
|
+
addECToUserMsg: true,
|
|
271
|
+
error: reason_theError,
|
|
272
|
+
additionalContent: {
|
|
273
|
+
reason: reason_theError,
|
|
274
|
+
rejectedPromise: p_passWhatIsThis_maybeThePromise,
|
|
275
|
+
},
|
|
276
|
+
systemVersion: global_settings_const_1.DyNTS_global_settings.systemVersion,
|
|
277
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
fsm_dynamo_1.DyFM_Log.error('globalErrorHandler (MULTILEVEL) ERROR:', error);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
this.asyncConstruct( /* extended */).catch((error) => {
|
|
285
|
+
if (error instanceof fsm_dynamo_1.DyFM_Error) {
|
|
286
|
+
if (error.additionalContent?.constructErrors?.length) {
|
|
287
|
+
error.additionalContent.constructErrors.forEach((errorItem) => {
|
|
288
|
+
fsm_dynamo_1.DyFM_Error.logSimple('(constructor asyncConstruct.catch) error:', errorItem);
|
|
289
|
+
/* if (errorItem instanceof DyFM_Error) {
|
|
290
|
+
errorItem.logSimple(`(constructor asyncConstruct.catch) error:\n`);
|
|
291
|
+
} else {
|
|
292
|
+
DyFM_Log.H_warn(
|
|
293
|
+
'(constructor asyncConstruct.catch) additional error content:\n',
|
|
294
|
+
errorItem
|
|
295
|
+
);
|
|
296
|
+
} */
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
fsm_dynamo_1.DyFM_Log.H_warn('(constructor asyncConstruct.catch) additional error content:\n', error?.additionalContent);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
fsm_dynamo_1.DyFM_Error.logSimple('(constructor asyncConstruct.catch) error:', error);
|
|
304
|
+
/* if (
|
|
305
|
+
!DyNTS_global_settings.log_settings.highDetailedLogs &&
|
|
306
|
+
(error instanceof DyFM_Error)
|
|
307
|
+
) {
|
|
308
|
+
error.logSimple(
|
|
309
|
+
`Application: "${this.params?.name}" start failed. (constructor asyncConstruct.catch)` +
|
|
310
|
+
'\n all error messages (from this stack):\n\n"' +
|
|
311
|
+
error._messages.join('"\n\n"') + '"\n\n'
|
|
312
|
+
);
|
|
313
|
+
} else if (error instanceof DyFM_Error) {
|
|
314
|
+
DyFM_Log.H_error(
|
|
315
|
+
`Application: "${this.params?.name}" start failed. (constructor asyncConstruct.catch)`,
|
|
316
|
+
`\n ERROR:`, error
|
|
317
|
+
);
|
|
318
|
+
} */
|
|
319
|
+
const message = error?.additionalContent?.constructErrors?.flatMap((errorItem) => {
|
|
320
|
+
return errorItem?._messages ?? [];
|
|
321
|
+
})?.join?.('\n') ??
|
|
322
|
+
error?.errors?.flatMap((errorItem) => errorItem?._messages ?? [errorItem?.message])?.join?.('\n') ??
|
|
323
|
+
error?.message ??
|
|
324
|
+
'UNKNOWN';
|
|
325
|
+
fsm_dynamo_1.DyFM_Log.testError('Application start failed:\n', message);
|
|
326
|
+
process.exit(1);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
async asyncConstruct(extended) {
|
|
330
|
+
if (this.fnLogs && this.deepLog)
|
|
331
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. asyncConstruct');
|
|
332
|
+
try {
|
|
333
|
+
this.systemControls.app.init = true;
|
|
334
|
+
this._params = this.getAppParams();
|
|
335
|
+
fsm_dynamo_1.DyFM_Log.log(`\n\n\n\n\n\n\n\n\n\n` +
|
|
336
|
+
`Starting ${this._params?.name}... ` +
|
|
337
|
+
/* `v${version}` + */
|
|
338
|
+
`\n\n\n\n\n\n\n\n\n\n`);
|
|
339
|
+
if (!this._params) {
|
|
340
|
+
throw new Error('getAppParams() must return a DyNTS_AppParams object!');
|
|
341
|
+
}
|
|
342
|
+
if (this.params.systemShortCodeName) {
|
|
343
|
+
global_settings_const_1.DyNTS_global_settings.systemShortCodeName = this.params.systemShortCodeName;
|
|
344
|
+
}
|
|
345
|
+
if (this.params.systemName) {
|
|
346
|
+
global_settings_const_1.DyNTS_global_settings.systemName = this.params.systemName;
|
|
347
|
+
fsm_dynamo_1.DyFM_error_defaults.issuerSystem = this.params.systemName;
|
|
348
|
+
}
|
|
349
|
+
if (this.params.version) {
|
|
350
|
+
global_settings_const_1.DyNTS_global_settings.systemVersion = this.params.version;
|
|
351
|
+
fsm_dynamo_1.DyFM_error_defaults.systemVersion = this.params.version;
|
|
352
|
+
}
|
|
353
|
+
process.stdout.write(String.fromCharCode(27) + ']0;' +
|
|
354
|
+
this._params?.name +
|
|
355
|
+
String.fromCharCode(7));
|
|
356
|
+
fsm_dynamo_1.DyFM_error_defaults.issuerSystem = this._params.systemName;
|
|
357
|
+
this.overrideDynamoNTSGlobalSettings?.();
|
|
358
|
+
if (global_settings_const_1.DyNTS_global_settings.log_settings.setup) {
|
|
359
|
+
fsm_dynamo_1.DyFM_Log.S_info(`env settings;\n`, {
|
|
360
|
+
systemName: global_settings_const_1.DyNTS_global_settings.systemName,
|
|
361
|
+
systemShortCodeName: global_settings_const_1.DyNTS_global_settings.systemShortCodeName,
|
|
362
|
+
systemVersion: global_settings_const_1.DyNTS_global_settings.systemVersion,
|
|
363
|
+
environment: global_settings_const_1.DyNTS_global_settings.env_settings.environment,
|
|
364
|
+
/* log_settings: DyNTS_global_settings.log_settings,
|
|
365
|
+
env_settings: DyNTS_global_settings.env_settings, */
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
this.globalService = global_service_1.DyNTS_GlobalService.getInstance();
|
|
369
|
+
await global_service_1.DyNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
370
|
+
global_service_1.DyNTS_GlobalService.setParams(this.params);
|
|
371
|
+
if (this.getPortSettings) {
|
|
372
|
+
this._portSettings = this.getPortSettings();
|
|
373
|
+
}
|
|
374
|
+
if (this.getCertificationSettings) {
|
|
375
|
+
this._cert = this.getCertificationSettings();
|
|
376
|
+
}
|
|
377
|
+
if (this.getApiBasePath) {
|
|
378
|
+
global_settings_const_1.DyNTS_global_settings.baseUrl = this.getApiBasePath();
|
|
379
|
+
}
|
|
380
|
+
if (this.getRoutingModules) {
|
|
381
|
+
this._routingModules = this.getRoutingModules();
|
|
382
|
+
// ezt egyelőre csak tesztelem, nem kerül be
|
|
383
|
+
/* if (
|
|
384
|
+
!DyNTS_global_settings.dontCreateDefaultRoute &&
|
|
385
|
+
!this._routingModules.some((routingModule: DyNTS_RoutingModule): boolean => routingModule.route === '/*')
|
|
386
|
+
) {
|
|
387
|
+
this._routingModules.push(
|
|
388
|
+
DyNTS_getStarRoute()
|
|
389
|
+
);
|
|
390
|
+
} */
|
|
391
|
+
}
|
|
392
|
+
if (this._params.dbUri) {
|
|
393
|
+
await this.startDB();
|
|
394
|
+
// createEntries csak akkor fut, ha a DB tényleg fel-jött.
|
|
395
|
+
// Ha a startDB jelezte a hibát, de továbbment, akkor a started flag false marad,
|
|
396
|
+
// és nem próbálunk meg írni egy nem létező kapcsolatra.
|
|
397
|
+
if (this.createEntries && this.systemControls.mongoose.started) {
|
|
398
|
+
await this.createEntries();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
fsm_dynamo_1.DyFM_Log.log(`\nNo database connection created.`);
|
|
403
|
+
}
|
|
404
|
+
if (this._routingModules?.length) {
|
|
405
|
+
if (this.logSetup)
|
|
406
|
+
fsm_dynamo_1.DyFM_Log.log('\nsetting up express routes...');
|
|
407
|
+
this.setSecurity();
|
|
408
|
+
await this.initExpresses();
|
|
409
|
+
await this.startExpresses();
|
|
410
|
+
if (this._security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
411
|
+
await this.mountOpenRoutes();
|
|
412
|
+
}
|
|
413
|
+
if (this._security !== route_security_enum_1.DyNTS_RouteSecurity.open && this._cert) {
|
|
414
|
+
await this.mountSecureRoutes();
|
|
415
|
+
}
|
|
416
|
+
// Generikus, auth-agnosztikus extension-point: custom middleware az API
|
|
417
|
+
// route-ok UTÁN, de a SPA static catch-all (mountStaticClient) ELŐTT.
|
|
418
|
+
await this.mountCustomMiddleware();
|
|
419
|
+
await this.mountStaticClient();
|
|
420
|
+
if (this.logSetup) {
|
|
421
|
+
fsm_dynamo_1.DyFM_Log.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
fsm_dynamo_1.DyFM_Log.warn(`\nNo routes mounted!`);
|
|
426
|
+
}
|
|
427
|
+
if (this.getRootServices) {
|
|
428
|
+
this._rootServices = await this.getRootServices();
|
|
429
|
+
}
|
|
430
|
+
if (this.postProcess) {
|
|
431
|
+
await this.postProcess().catch((error) => {
|
|
432
|
+
fsm_dynamo_1.DyFM_Error.logSimple(`"${this._params.name}" postProcess failed:`, error);
|
|
433
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(error);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
// FR-193 — bedrock OOM korai-figyelmeztetés: feltelepítjük a heap-watchdogot, ha
|
|
437
|
+
// engedélyezve (DyNTS_global_settings.memoryGuard.enabled, default true). Biztonságos:
|
|
438
|
+
// a guard egy könnyű setInterval, ami SOHA nem dob; csak near-OOM küszöböknél hagy
|
|
439
|
+
// tartós nyomot az error-sinkbe, mielőtt a fatal heap-OOM megölné a process-t.
|
|
440
|
+
try {
|
|
441
|
+
if (global_settings_const_1.DyNTS_global_settings.memoryGuard?.enabled) {
|
|
442
|
+
memory_guard_service_1.DyNTS_MemoryGuard.getInstance().install();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
catch (memoryGuardError) {
|
|
446
|
+
fsm_dynamo_1.DyFM_Log.warn('[DyNTS_MemoryGuard] auto-install skipped (non-fatal):', memoryGuardError);
|
|
447
|
+
}
|
|
448
|
+
if (!extended) {
|
|
449
|
+
await this.ready();
|
|
450
|
+
if (this.params.title) {
|
|
451
|
+
fsm_dynamo_1.DyFM_Log.success(this.params.title);
|
|
452
|
+
}
|
|
453
|
+
fsm_dynamo_1.DyFM_Log.info(`Version: ${this.params.version}`);
|
|
454
|
+
/* DyFM_Log.info(`NTS Version: ${this.ntsVersion}`); */
|
|
455
|
+
fsm_dynamo_1.DyFM_Log.H_success(`${this.params.name} started successfully.`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
this.constructErrors.push(error);
|
|
460
|
+
if (this.deepLog) {
|
|
461
|
+
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
462
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed (in asyncConstruct (highDetailedLog)). `, `\n\n construct ERRORS:`, this.constructErrors, '\n\nlast error:', error);
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed (in asyncConstruct). `, `\n\n construct ERRORS:`, this.getSimplifiedConstructErrors(), '\n\nlast error:', error instanceof fsm_dynamo_1.DyFM_Error ? error.getErrorSimplified() : error);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
469
|
+
...this._getDefaultErrorSettings('asyncConstruct', error),
|
|
470
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-001`,
|
|
471
|
+
additionalContent: {
|
|
472
|
+
constructErrors: this.constructErrors,
|
|
473
|
+
systemControls: this.systemControls,
|
|
474
|
+
systemReadies: {
|
|
475
|
+
app: this.systemControls.app.getIsReady(),
|
|
476
|
+
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
477
|
+
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
478
|
+
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
async ready(timeout = this.defaultReadyTimeout) {
|
|
485
|
+
try {
|
|
486
|
+
if (this.fnLogs)
|
|
487
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. ready');
|
|
488
|
+
await fsm_dynamo_1.DyFM_Async.delay(100);
|
|
489
|
+
let ready = false;
|
|
490
|
+
const start = +new Date();
|
|
491
|
+
if (this.constructErrors.length) {
|
|
492
|
+
if (this.deepLog) {
|
|
493
|
+
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
494
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 1)`, `\n construct ERRORS:`, this.constructErrors);
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 1)`, `\n construct ERRORS:`, this.getSimplifiedConstructErrors());
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
501
|
+
...this._getDefaultErrorSettings('ready', new Error(`"${this._params.name}" start failed.`)),
|
|
502
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R01`,
|
|
503
|
+
additionalContent: this.constructErrors.length === 1 ?
|
|
504
|
+
{ error: this.constructErrors[0] } :
|
|
505
|
+
{ errors: this.constructErrors },
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
while (!ready && +new Date() - start < timeout) {
|
|
509
|
+
if (this.systemControls.app.init) {
|
|
510
|
+
ready = (this.systemControls.mongoose.getIsReady() &&
|
|
511
|
+
this.systemControls.httpServer.getIsReady() &&
|
|
512
|
+
this.systemControls.httpsServer.getIsReady());
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
fsm_dynamo_1.DyFM_Log.error(`"${this._params.name}" APP NOT INITIALIZED while trying to get ready.`);
|
|
516
|
+
}
|
|
517
|
+
if (!ready) {
|
|
518
|
+
await fsm_dynamo_1.DyFM_Async.wait(100);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (timeout < +new Date() - start) {
|
|
522
|
+
if (this.deepLog) {
|
|
523
|
+
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
524
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; TIMEOUT check)`, `\n construct ERRORS:`, this.constructErrors);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; TIMEOUT check)`, `\n construct ERRORS:`, this.getSimplifiedConstructErrors());
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
531
|
+
...this._getDefaultErrorSettings('ready', new Error(`"${this._params.name}" start failed. TIMEOUT`)),
|
|
532
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R02`,
|
|
533
|
+
additionalContent: {
|
|
534
|
+
constructErrors: this.constructErrors,
|
|
535
|
+
systemControls: this.systemControls,
|
|
536
|
+
systemReadies: {
|
|
537
|
+
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
538
|
+
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
539
|
+
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
if (this.constructErrors.length) {
|
|
545
|
+
if (this.deepLog) {
|
|
546
|
+
if (global_settings_const_1.DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
547
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 2)`, `\n construct ERRORS:`, this.constructErrors);
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
fsm_dynamo_1.DyFM_Log.H_error(`"${this._params.name}" start failed. (ready; constructErrors check 2)`, `\n construct ERRORS:`, this.getSimplifiedConstructErrors());
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
554
|
+
...this._getDefaultErrorSettings('ready', new Error(`"${this._params.name}" start failed.`)),
|
|
555
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R03`,
|
|
556
|
+
additionalContent: this.constructErrors,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (ready) {
|
|
560
|
+
this.systemControls.app.started = true;
|
|
561
|
+
if (this.fnLogs && this.deepLog)
|
|
562
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. ready: return');
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
this.systemControls.app.started = false;
|
|
566
|
+
let msg = `"${this._params.name}" start failed. UNKNOWN`;
|
|
567
|
+
if (this.systemControls.mongoose.init && !this.systemControls.mongoose.started) {
|
|
568
|
+
msg += `\nMongoose start failed.`;
|
|
569
|
+
}
|
|
570
|
+
if (this.systemControls.httpServer.init && !this.systemControls.httpServer.started) {
|
|
571
|
+
msg += `\nHTTP Server start failed.`;
|
|
572
|
+
}
|
|
573
|
+
if (this.systemControls.httpsServer.init && !this.systemControls.httpsServer.started) {
|
|
574
|
+
msg += `\nHTTPS Server start failed.`;
|
|
575
|
+
}
|
|
576
|
+
fsm_dynamo_1.DyFM_Log.error(msg, this.constructErrors);
|
|
577
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
578
|
+
...this._getDefaultErrorSettings('ready', new Error(msg)),
|
|
579
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-R04`,
|
|
580
|
+
additionalContent: {
|
|
581
|
+
constructErrors: this.constructErrors,
|
|
582
|
+
systemControls: this.systemControls,
|
|
583
|
+
systemReadies: {
|
|
584
|
+
app: this.systemControls.app.getIsReady(),
|
|
585
|
+
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
586
|
+
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
587
|
+
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
588
|
+
},
|
|
589
|
+
},
|
|
590
|
+
error: this.constructErrors?.[0] ?? new Error(),
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
595
|
+
...this._getDefaultErrorSettings('ready', error),
|
|
596
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-READY0`,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
getSimplifiedConstructErrors() {
|
|
601
|
+
return this.constructErrors.map((error) => {
|
|
602
|
+
if (error instanceof fsm_dynamo_1.DyFM_Error) {
|
|
603
|
+
return error.getErrorSimplified();
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
return error;
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
async stop(dontLog) {
|
|
611
|
+
try {
|
|
612
|
+
fsm_dynamo_1.DyFM_Log.info('\nstopping server...\n');
|
|
613
|
+
await this.ready();
|
|
614
|
+
if (this.started) {
|
|
615
|
+
if (this.systemControls.mongoose.init) {
|
|
616
|
+
fsm_dynamo_1.DyFM_Log.info(`\nstopping Mongoose....`);
|
|
617
|
+
let tryCount = 0;
|
|
618
|
+
while (!this.systemControls.mongoose.started &&
|
|
619
|
+
!this.constructErrors.length &&
|
|
620
|
+
tryCount++ < 10) {
|
|
621
|
+
fsm_dynamo_1.DyFM_Log.warn(`Mongoose not even started yet....`);
|
|
622
|
+
await fsm_dynamo_1.DyFM_Async.wait(fsm_dynamo_1.second);
|
|
623
|
+
}
|
|
624
|
+
this.systemControls.mongoose.started = false;
|
|
625
|
+
if (this.mongoose) {
|
|
626
|
+
await fsm_dynamo_1.DyFM_Array.asyncForEach(Object.keys(this.mongoose.models), async (modelName) => {
|
|
627
|
+
this.mongoose.deleteModel(modelName);
|
|
628
|
+
});
|
|
629
|
+
const disconnect = new Promise((resolve) => {
|
|
630
|
+
this.mongoose.connection.on('disconnecting', () => {
|
|
631
|
+
resolve();
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
await this.mongoose.disconnect();
|
|
635
|
+
await this.mongoose.connection.close();
|
|
636
|
+
await disconnect;
|
|
637
|
+
this.mongoose.connection.removeAllListeners();
|
|
638
|
+
while (this.mongoose.connection.readyState !== 0 &&
|
|
639
|
+
!this.constructErrors.length) {
|
|
640
|
+
fsm_dynamo_1.DyFM_Log.warn(`\nMongoose still not disconnected....`);
|
|
641
|
+
await fsm_dynamo_1.DyFM_Async.wait(fsm_dynamo_1.second);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
fsm_dynamo_1.DyFM_Log.error(`\nMongoose not found.`);
|
|
646
|
+
}
|
|
647
|
+
this.systemControls.mongoose.init = false;
|
|
648
|
+
}
|
|
649
|
+
if (this.systemControls.httpServer.init) {
|
|
650
|
+
this.systemControls.httpServer.started = false;
|
|
651
|
+
if (this.httpServer) {
|
|
652
|
+
await new Promise((resolve) => {
|
|
653
|
+
this.httpServer.close(resolve);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
fsm_dynamo_1.DyFM_Log.error(`\nHTTP Server not found.`);
|
|
658
|
+
}
|
|
659
|
+
this.systemControls.httpServer.init = false;
|
|
660
|
+
}
|
|
661
|
+
if (this.systemControls.httpsServer.init) {
|
|
662
|
+
this.systemControls.httpsServer.started = false;
|
|
663
|
+
if (this.httpsServer) {
|
|
664
|
+
await new Promise((resolve) => {
|
|
665
|
+
this.httpsServer.close(resolve);
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
fsm_dynamo_1.DyFM_Log.error(`\nHTTPS Server not found.`);
|
|
670
|
+
}
|
|
671
|
+
this.systemControls.httpsServer.init = false;
|
|
672
|
+
}
|
|
673
|
+
await fsm_dynamo_1.DyFM_Async.wait(fsm_dynamo_1.second);
|
|
674
|
+
if (!dontLog) {
|
|
675
|
+
fsm_dynamo_1.DyFM_Log.H_log(`"${this._params.name}" stopped successfully.`);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
catch (error) {
|
|
680
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
681
|
+
...this._getDefaultErrorSettings('stop', error),
|
|
682
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-STOP0`,
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
*
|
|
688
|
+
*/
|
|
689
|
+
async startDB() {
|
|
690
|
+
if (this.fnLogs && this.deepLog)
|
|
691
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. startDB');
|
|
692
|
+
else if (this.logSetup)
|
|
693
|
+
fsm_dynamo_1.DyFM_Log.log('\nstarting DB connection...');
|
|
694
|
+
if (!this._params.dbUri) {
|
|
695
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
696
|
+
...this._getDefaultErrorSettings('startDB', new Error('DB URI is not set.')),
|
|
697
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
if (!this._params.dbOptions) {
|
|
701
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
702
|
+
...this._getDefaultErrorSettings('startDB', new Error('DB OPTIONS are not set.')),
|
|
703
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
if (this.systemControls.mongoose.init || this.systemControls.mongoose.started) {
|
|
707
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
708
|
+
...this._getDefaultErrorSettings('startDB', new Error('Mongoose is already initialized.')),
|
|
709
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
try {
|
|
713
|
+
await new Promise((resolve, reject) => {
|
|
714
|
+
this.systemControls.mongoose.init = true;
|
|
715
|
+
this.mongoose.connection
|
|
716
|
+
.once('open', () => {
|
|
717
|
+
this.systemControls.mongoose.started = true;
|
|
718
|
+
fsm_dynamo_1.DyFM_Log.success(`\nConnected to MongoDB (${this._params.dbUri})\n`);
|
|
719
|
+
resolve();
|
|
720
|
+
})
|
|
721
|
+
.on('error', (error) => {
|
|
722
|
+
if (!this.systemControls.mongoose.started) {
|
|
723
|
+
// Initial DB-csatlakozás sikertelen:
|
|
724
|
+
// jelezzük a hibát (log + globalErrorHandler), de NEM szakítjuk meg az
|
|
725
|
+
// App startup-ot (nincs constructErrors push, nincs reject).
|
|
726
|
+
// A mongoose.init-et resetteljük, hogy a ready() ne várjon a DB-re.
|
|
727
|
+
// Ha a mongoose később mégis tudna csatlakozni, az 'open' event
|
|
728
|
+
// beállítja a started flag-et, így a runtime DB-műveletek elindulnak.
|
|
729
|
+
this.systemControls.mongoose.init = false;
|
|
730
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
731
|
+
...this._getDefaultErrorSettings('startDB', error),
|
|
732
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB1`,
|
|
733
|
+
message: `Unable to connect to MongoDB server (${this._params.dbUri}), ` +
|
|
734
|
+
`ERROR: ${error}`,
|
|
735
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.serious,
|
|
736
|
+
});
|
|
737
|
+
fsm_dynamo_1.DyFM_Log.H_error(`\nUnable to connect to MongoDB server (${this._params.dbUri}).` +
|
|
738
|
+
`\nServer will continue WITHOUT DB connection.` +
|
|
739
|
+
`\nDB-using endpoints will fail at runtime until connection recovers.`);
|
|
740
|
+
if (this.debugLog)
|
|
741
|
+
fsm_dynamo_1.DyFM_Log.S_error(`\nMongoDB connect ERROR: `, error);
|
|
742
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
743
|
+
resolve();
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
if (this.debugLog)
|
|
747
|
+
fsm_dynamo_1.DyFM_Log.error('\nMongoDB ERROR: ', error);
|
|
748
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
749
|
+
...this._getDefaultErrorSettings('mongoose.connection.on(error)', error),
|
|
750
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB2`,
|
|
751
|
+
message: `MongoDB ERROR: ${error}`,
|
|
752
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
753
|
+
});
|
|
754
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
try {
|
|
758
|
+
this.mongoose.connect(this._params.dbUri, this._params.dbOptions
|
|
759
|
+
/* {
|
|
760
|
+
directConnection: true,
|
|
761
|
+
} */
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
catch (error) {
|
|
765
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
766
|
+
...this._getDefaultErrorSettings('startDB', error),
|
|
767
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB3`,
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
catch (error) {
|
|
773
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
774
|
+
...this._getDefaultErrorSettings('startDB', error),
|
|
775
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SDB0`,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
// 2026-06-20 — Mongo reconnect-guard. A MongoDB-driver a hostnevet connect-kor EGYSZER
|
|
779
|
+
// resolválja + cache-eli az IP-t; ha a Mongo-konténert recreate-elik (új docker-network IP),
|
|
780
|
+
// a driver a HALOTT IP-n ragad → ECONNREFUSED + buffering-timeout, és a service magától SOHA
|
|
781
|
+
// nem áll vissza. A guard sustained-disconnect (readyState !== 1) esetén — a driver saját
|
|
782
|
+
// grace-e UTÁN — TELJES disconnect()+connect()-et csinál → ÚJ MongoClient → ÚJ DNS-resolve →
|
|
783
|
+
// új IP → reconnect. Best-effort, always-on, healthy connection-t (===1) SOHA nem bánt; csak
|
|
784
|
+
// konténer-IP-frissítés, nem ír adatot. Lásd: mongo-reconnect-guard.util.ts.
|
|
785
|
+
try {
|
|
786
|
+
(0, mongo_reconnect_guard_util_1.startMongoReconnectGuard)({
|
|
787
|
+
getReadyState: () => this.mongoose.connection.readyState,
|
|
788
|
+
reconnect: async () => {
|
|
789
|
+
await this.mongoose.disconnect().catch(() => undefined);
|
|
790
|
+
await this.mongoose.connect(this._params.dbUri, this._params.dbOptions);
|
|
791
|
+
},
|
|
792
|
+
log: (msg) => fsm_dynamo_1.DyFM_Log.warn(msg),
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
catch (guardErr) {
|
|
796
|
+
fsm_dynamo_1.DyFM_Log.warn(`[mongo-reconnect-guard] failed to start (non-fatal): ${guardErr instanceof Error ? guardErr.message : String(guardErr)}`);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
*
|
|
801
|
+
*/
|
|
802
|
+
async initExpresses() {
|
|
803
|
+
if (this.fnLogs && this.deepLog)
|
|
804
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. initExpresses');
|
|
805
|
+
try {
|
|
806
|
+
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
807
|
+
if (this._portSettings.httpPort === undefined || this._portSettings.httpPort === null) {
|
|
808
|
+
let errorMsg = `\nYou have open routes, but httpPort is not set!` +
|
|
809
|
+
`\nThere are ${this._routingModules.filter(m => m.security != route_security_enum_1.DyNTS_RouteSecurity.secure).length} open/both routes` +
|
|
810
|
+
`\nroot security: ${this._security}` +
|
|
811
|
+
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
812
|
+
errorMsg += '\n\nThe routes setted to use open server:';
|
|
813
|
+
this._routingModules.forEach((module) => {
|
|
814
|
+
if (module.security != route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
815
|
+
errorMsg += `\n ${module.route} (security: ${module.security})`;
|
|
816
|
+
errorMsg += `\n subroutes using open sever:`;
|
|
817
|
+
module.endpoints.forEach((endpoint) => {
|
|
818
|
+
if (endpoint.security != route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
819
|
+
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
const error = new Error(`Open routes cannot be established!\n${errorMsg}`);
|
|
825
|
+
const errorStack = error.stack.split('\n');
|
|
826
|
+
errorStack.splice(1, 2);
|
|
827
|
+
error.stack = errorStack.join('\n');
|
|
828
|
+
fsm_dynamo_1.DyFM_Log.error(errorMsg);
|
|
829
|
+
throw error;
|
|
830
|
+
}
|
|
831
|
+
await this.initOpenExpress();
|
|
832
|
+
}
|
|
833
|
+
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
834
|
+
if (!this._cert || !this._portSettings.httpsPort) {
|
|
835
|
+
let errorMsg = `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
836
|
+
`\nThere are ${this._routingModules.filter(m => m.security && m.security !== route_security_enum_1.DyNTS_RouteSecurity.open).length} secure routes` +
|
|
837
|
+
`\nroot security: ${this._security}` +
|
|
838
|
+
`\nset...` +
|
|
839
|
+
`\n(missing exact howto...)` +
|
|
840
|
+
/* `\n httpsPort and` +
|
|
841
|
+
`\n cert: {` +
|
|
842
|
+
`\n keyPath: FileSystem.PathLike,` +
|
|
843
|
+
`\n certPath: FileSystem.PathLike,` +
|
|
844
|
+
`\n }` + */
|
|
845
|
+
`\nin DynamoBEServer - getRoutingModules() to enable secure routes.`;
|
|
846
|
+
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
847
|
+
this._routingModules.forEach((module) => {
|
|
848
|
+
if (module.security && module.security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
849
|
+
errorMsg += `\n ${module.route} (security: ${module.security})`;
|
|
850
|
+
errorMsg += `\n location: ${module.stackLocation}`;
|
|
851
|
+
errorMsg += `\n subroutes using secure sever:`;
|
|
852
|
+
module.endpoints.forEach((endpoint) => {
|
|
853
|
+
if (endpoint.security && endpoint.security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
854
|
+
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
855
|
+
errorMsg += `\n location: ${endpoint.stackLocation}`;
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
const error = new Error(`Secure routes cannot be established!\n${errorMsg}`);
|
|
861
|
+
const errorStack = error.stack.split('\n');
|
|
862
|
+
errorStack.splice(1, 2);
|
|
863
|
+
error.stack = errorStack.join('\n');
|
|
864
|
+
fsm_dynamo_1.DyFM_Log.error(errorMsg);
|
|
865
|
+
throw error;
|
|
866
|
+
}
|
|
867
|
+
await this.initSecureExpress();
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
catch (error) {
|
|
871
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
872
|
+
...this._getDefaultErrorSettings('initExpresses', error),
|
|
873
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-IE0`,
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
*
|
|
879
|
+
*/
|
|
880
|
+
async initOpenExpress() {
|
|
881
|
+
if (this.fnLogs)
|
|
882
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. initOpenExpress');
|
|
883
|
+
this.openExpress = Express();
|
|
884
|
+
this.openExpress.set('maxHeaderSize', 10 * fsm_dynamo_1.megabyte); // 1024 * 1024 * 10, // 10MB
|
|
885
|
+
this.openExpress.use(BodyParser.urlencoded(this._portSettings.httpUrlencoded));
|
|
886
|
+
this.openExpress.use(BodyParser.json(this._portSettings.httpJson));
|
|
887
|
+
// FR-041 — CORS allowlist enforcement. No-op if getCorsSettings() is not overridden.
|
|
888
|
+
this.mountCors(this.openExpress);
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
*
|
|
892
|
+
*/
|
|
893
|
+
async initSecureExpress() {
|
|
894
|
+
if (this.fnLogs)
|
|
895
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. initSecureExpress');
|
|
896
|
+
this.secureExpress = Express();
|
|
897
|
+
this.secureExpress.use(BodyParser.urlencoded(this._portSettings.httpsUrlencoded));
|
|
898
|
+
this.secureExpress.use(BodyParser.json(this._portSettings.httpsJson));
|
|
899
|
+
// FR-041 — CORS allowlist enforcement (same as open express).
|
|
900
|
+
this.mountCors(this.secureExpress);
|
|
901
|
+
const options = {
|
|
902
|
+
key: FileSystem.readFileSync(this._cert.keyPath),
|
|
903
|
+
cert: FileSystem.readFileSync(this._cert.certPath),
|
|
904
|
+
maxHeaderSize: 10 * fsm_dynamo_1.megabyte, // 1024 * 1024 * 10, // 10MB
|
|
905
|
+
};
|
|
906
|
+
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
*
|
|
910
|
+
*/
|
|
911
|
+
async startExpresses() {
|
|
912
|
+
if (this.fnLogs && this.deepLog)
|
|
913
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. startExpresses');
|
|
914
|
+
try {
|
|
915
|
+
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
916
|
+
await new Promise((resolve, reject) => {
|
|
917
|
+
this.systemControls.httpsServer.init = true;
|
|
918
|
+
this.httpsServer
|
|
919
|
+
.listen(this._portSettings.httpsPort, this.params.secureHost, this.params.expressBacklog, () => {
|
|
920
|
+
this.systemControls.httpsServer.started = true;
|
|
921
|
+
fsm_dynamo_1.DyFM_Log.success(`\nHTTPS (secure) server is listening on port: ` +
|
|
922
|
+
`${this.params.secureHost}:${this._portSettings.httpsPort}`);
|
|
923
|
+
resolve();
|
|
924
|
+
})
|
|
925
|
+
.on('error', (error) => {
|
|
926
|
+
if (this.debugLog)
|
|
927
|
+
fsm_dynamo_1.DyFM_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
928
|
+
if (!this.systemControls.httpsServer.started) {
|
|
929
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
930
|
+
...this._getDefaultErrorSettings('startExpresses', error),
|
|
931
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE1`,
|
|
932
|
+
message: `HTTPS (secure) start server ERROR`,
|
|
933
|
+
});
|
|
934
|
+
this.constructErrors.push(d_error);
|
|
935
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
936
|
+
reject(d_error);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
940
|
+
...this._getDefaultErrorSettings('httpsServer.on(error)', error),
|
|
941
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE2`,
|
|
942
|
+
message: `HTTPS (secure) server ERROR`,
|
|
943
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.serious,
|
|
944
|
+
});
|
|
945
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
946
|
+
}
|
|
947
|
+
})
|
|
948
|
+
.on('uncaughtException', (exception) => {
|
|
949
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
950
|
+
...this._getDefaultErrorSettings('httpsServer.on(uncaughtException)', exception),
|
|
951
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE3`,
|
|
952
|
+
message: `HTTPS (secure) server uncaughtException`,
|
|
953
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
954
|
+
});
|
|
955
|
+
if (this.debugLog)
|
|
956
|
+
fsm_dynamo_1.DyFM_Log.warn(`\nHTTPS (secure) server uncaughtException`, d_error);
|
|
957
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
if (this._security && this._security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
962
|
+
this.systemControls.httpServer.init = true;
|
|
963
|
+
await new Promise((resolve, reject) => {
|
|
964
|
+
this.httpServer = this.openExpress
|
|
965
|
+
.listen(this._portSettings.httpPort, this.params.openHost, this.params.expressBacklog, () => {
|
|
966
|
+
this.systemControls.httpServer.started = true;
|
|
967
|
+
const resolvedPort = this.httpServer?.address?.()?.['port'] ?? this._portSettings.httpPort;
|
|
968
|
+
if (this._portSettings.httpPort === 0) {
|
|
969
|
+
fsm_dynamo_1.DyFM_Log.H_warn(`\nHTTP (open) server is using a randomly selected port by the OS: ${resolvedPort}` +
|
|
970
|
+
`\n (httpPort was set to 0 — this is intended for testing only)`);
|
|
971
|
+
}
|
|
972
|
+
fsm_dynamo_1.DyFM_Log.success(`\nHTTP (open) server is listening on port: ` +
|
|
973
|
+
`${this.params.openHost}:${resolvedPort}`);
|
|
974
|
+
resolve();
|
|
975
|
+
})
|
|
976
|
+
.on('error', (error) => {
|
|
977
|
+
if (this.debugLog)
|
|
978
|
+
fsm_dynamo_1.DyFM_Log.error(`\nHTTP (open) server ERROR`, error);
|
|
979
|
+
if (!this.systemControls.httpServer.started) {
|
|
980
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
981
|
+
...this._getDefaultErrorSettings('startExpresses', error),
|
|
982
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE3`,
|
|
983
|
+
message: `HTTP (open) start server ERROR`,
|
|
984
|
+
});
|
|
985
|
+
this.constructErrors.push(d_error);
|
|
986
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
987
|
+
reject(d_error);
|
|
988
|
+
}
|
|
989
|
+
else {
|
|
990
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
991
|
+
...this._getDefaultErrorSettings('httpServer.on(error)', error),
|
|
992
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE4`,
|
|
993
|
+
message: `HTTP (open) server ERROR`,
|
|
994
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.serious,
|
|
995
|
+
});
|
|
996
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
997
|
+
}
|
|
998
|
+
})
|
|
999
|
+
.on('uncaughtException', (exception) => {
|
|
1000
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
1001
|
+
...this._getDefaultErrorSettings('httpServer.on(uncaughtException)', exception),
|
|
1002
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE5`,
|
|
1003
|
+
message: `HTTP (open) server uncaughtException`,
|
|
1004
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.critical,
|
|
1005
|
+
});
|
|
1006
|
+
if (this.debugLog) {
|
|
1007
|
+
fsm_dynamo_1.DyFM_Log.warn(`\nHTTP (open) server uncaughtException`, d_error);
|
|
1008
|
+
}
|
|
1009
|
+
global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
catch (error) {
|
|
1015
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
1016
|
+
...this._getDefaultErrorSettings('startExpresses', error),
|
|
1017
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-SE0`,
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
*
|
|
1023
|
+
*/
|
|
1024
|
+
async expressErrorHandling(error, req, res, next) {
|
|
1025
|
+
try {
|
|
1026
|
+
if (error) {
|
|
1027
|
+
const d_error = new fsm_dynamo_1.DyFM_Error({
|
|
1028
|
+
...this._getDefaultErrorSettings('expressErrorHandling', error),
|
|
1029
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-EEH1`,
|
|
1030
|
+
message: `Express ERROR`,
|
|
1031
|
+
additionalContent: {
|
|
1032
|
+
req,
|
|
1033
|
+
res,
|
|
1034
|
+
},
|
|
1035
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.error,
|
|
1036
|
+
});
|
|
1037
|
+
await global_service_1.DyNTS_GlobalService.globalErrorHandler?.(d_error, req, res);
|
|
1038
|
+
res.send(error);
|
|
1039
|
+
}
|
|
1040
|
+
else {
|
|
1041
|
+
fsm_dynamo_1.DyFM_Log.H_error('WTF??? express error; without error?...' +
|
|
1042
|
+
'\nerr:', error, '\nreq:', req, '\nres:', res);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
catch (error) {
|
|
1046
|
+
fsm_dynamo_1.DyFM_Log.H_error('MULTILEVEL ERROR (expressErrorHandling)....' +
|
|
1047
|
+
'\n', error);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
*
|
|
1052
|
+
*/
|
|
1053
|
+
async mountSecureRoutes() {
|
|
1054
|
+
try {
|
|
1055
|
+
if (this.fnLogs && this.deepLog)
|
|
1056
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. mountSecureRoutes');
|
|
1057
|
+
if (!this.secureExpress) {
|
|
1058
|
+
throw new Error('secureExpress was not initialized. ' +
|
|
1059
|
+
'Secure routes require getCertificationSettings and httpsPort, and cert files must exist.' +
|
|
1060
|
+
'\n\nYou need to set security to secure or both in any route and set httpsPort in getPortSettings.' +
|
|
1061
|
+
'\n\nYou need to set cert files in getCertificationSettings.');
|
|
1062
|
+
}
|
|
1063
|
+
this.secureExpress.use((error, req, res, next) => this.expressErrorHandling(error, req, res, next));
|
|
1064
|
+
await fsm_dynamo_1.DyFM_Array.asyncForEach(this._routingModules, async (module) => {
|
|
1065
|
+
if (module.security !== route_security_enum_1.DyNTS_RouteSecurity.open) {
|
|
1066
|
+
if (this.logSetup) {
|
|
1067
|
+
fsm_dynamo_1.DyFM_Log.log(`route mount (secure): ${module.route}`);
|
|
1068
|
+
}
|
|
1069
|
+
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
1070
|
+
if (1 < existingRoutes.length) {
|
|
1071
|
+
const error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
1072
|
+
/* const errorStack: string[] = error.stack.split('\n');
|
|
1073
|
+
|
|
1074
|
+
errorStack.splice(1, 4);
|
|
1075
|
+
error.stack = errorStack.join('\n'); */
|
|
1076
|
+
error.stack = module.stackLocation;
|
|
1077
|
+
fsm_dynamo_1.DyFM_Log.S_error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1078
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
1079
|
+
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
1080
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MSR1`,
|
|
1081
|
+
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
this.secureExpress.use(module.route, module.secureRouter);
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
catch (error) {
|
|
1089
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
1090
|
+
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
1091
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MSR0`,
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
*
|
|
1097
|
+
*/
|
|
1098
|
+
async mountOpenRoutes() {
|
|
1099
|
+
try {
|
|
1100
|
+
if (this.fnLogs && this.deepLog)
|
|
1101
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. mountOpenRoutes');
|
|
1102
|
+
if (!this.openExpress) {
|
|
1103
|
+
throw new Error('openExpress was not initialized. Open routes require getOpenExpress and httpPort.' +
|
|
1104
|
+
'\n\nYou need to set security to open or both in any route and set httpPort in getPortSettings.');
|
|
1105
|
+
}
|
|
1106
|
+
this.openExpress.use((error, req, res, next) => this.expressErrorHandling(error, req, res, next));
|
|
1107
|
+
await fsm_dynamo_1.DyFM_Array.asyncForEach(this._routingModules, async (module) => {
|
|
1108
|
+
if (module.security !== route_security_enum_1.DyNTS_RouteSecurity.secure) {
|
|
1109
|
+
if (this.logSetup) {
|
|
1110
|
+
fsm_dynamo_1.DyFM_Log.log(`route mount (open): ${module.route}`);
|
|
1111
|
+
}
|
|
1112
|
+
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
1113
|
+
if (1 < existingRoutes.length) {
|
|
1114
|
+
const error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
1115
|
+
/* const errorStack: string[] = error.stack.split('\n');
|
|
1116
|
+
|
|
1117
|
+
errorStack.splice(1, 4);
|
|
1118
|
+
error.stack = errorStack.join('\n'); */
|
|
1119
|
+
error.stack = module.stackLocation;
|
|
1120
|
+
fsm_dynamo_1.DyFM_Log.S_error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1121
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
1122
|
+
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
1123
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MOR1`,
|
|
1124
|
+
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
this.openExpress.use(module.route, module.openRouter);
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
catch (error) {
|
|
1132
|
+
throw new fsm_dynamo_1.DyFM_Error({
|
|
1133
|
+
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
1134
|
+
errorCode: `${global_settings_const_1.DyNTS_global_settings.systemShortCodeName}|DyNTS-AS0-MOR0`,
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* FR-041 — CORS middleware. Echoes a matching `Access-Control-Allow-Origin`
|
|
1140
|
+
* for any request whose Origin header is in `getCorsSettings().allowedOrigins`,
|
|
1141
|
+
* adds the canonical `Access-Control-*` companion headers, and short-circuits
|
|
1142
|
+
* the OPTIONS preflight with a 204.
|
|
1143
|
+
*
|
|
1144
|
+
* No-op when the subclass does NOT override `getCorsSettings()` — preserves
|
|
1145
|
+
* back-compat for apps that have always been same-origin and never needed
|
|
1146
|
+
* CORS (the typical pre-FR-041 case).
|
|
1147
|
+
*
|
|
1148
|
+
* Why hand-rolled instead of the `cors` npm package:
|
|
1149
|
+
* - ~30 lines, zero new dependency.
|
|
1150
|
+
* - Full control over Vary/credentials/preflight semantics.
|
|
1151
|
+
* - Aligns with FDP "no unnecessary deps" philosophy.
|
|
1152
|
+
*/
|
|
1153
|
+
mountCors(express) {
|
|
1154
|
+
const settings = this.getCorsSettings?.();
|
|
1155
|
+
if (!settings) {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const allowCreds = settings.allowCredentials !== false;
|
|
1159
|
+
const methods = settings.allowedMethods ?? [
|
|
1160
|
+
'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS',
|
|
1161
|
+
];
|
|
1162
|
+
const headers = settings.allowedHeaders ?? [
|
|
1163
|
+
'Authorization', 'Content-Type', 'X-Admin-Key', 'X-Requested-With',
|
|
1164
|
+
];
|
|
1165
|
+
const exposed = settings.exposedHeaders ?? [
|
|
1166
|
+
'Content-Length', 'Content-Type',
|
|
1167
|
+
];
|
|
1168
|
+
const maxAge = settings.maxAgeSeconds ?? 86400;
|
|
1169
|
+
const isAllowed = (origin) => {
|
|
1170
|
+
if (settings.allowedOrigins === '*')
|
|
1171
|
+
return true;
|
|
1172
|
+
if (typeof settings.allowedOrigins === 'function') {
|
|
1173
|
+
return settings.allowedOrigins(origin);
|
|
1174
|
+
}
|
|
1175
|
+
return settings.allowedOrigins.includes(origin);
|
|
1176
|
+
};
|
|
1177
|
+
express.use((req, res, next) => {
|
|
1178
|
+
const origin = req.headers.origin;
|
|
1179
|
+
if (origin && isAllowed(origin)) {
|
|
1180
|
+
// Echo the matching origin (NOT wildcard) because credentials require it.
|
|
1181
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
1182
|
+
if (allowCreds) {
|
|
1183
|
+
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
1184
|
+
}
|
|
1185
|
+
res.setHeader('Access-Control-Allow-Methods', methods.join(', '));
|
|
1186
|
+
res.setHeader('Access-Control-Allow-Headers', headers.join(', '));
|
|
1187
|
+
res.setHeader('Access-Control-Expose-Headers', exposed.join(', '));
|
|
1188
|
+
res.setHeader('Access-Control-Max-Age', String(maxAge));
|
|
1189
|
+
res.setHeader('Vary', 'Origin');
|
|
1190
|
+
}
|
|
1191
|
+
if (req.method === 'OPTIONS') {
|
|
1192
|
+
res.status(204).end();
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
next();
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Generikus, auth-agnosztikus extension-point orchestrator. A `registerCustomMiddleware`
|
|
1200
|
+
* hookot hívja (ha a subclass override-olja) minden AKTÍV Express instance-ra
|
|
1201
|
+
* (open + secure), az API route-ok UTÁN, de a SPA static catch-all (`app.get('*')`)
|
|
1202
|
+
* ELŐTT — ez az EGYETLEN korrekt pont egy sub-path middleware-hez (pl. reverse-proxy),
|
|
1203
|
+
* mert a catch-all minden utána mountolt route-ot elnyel. No-op ha nincs override (back-compat).
|
|
1204
|
+
*/
|
|
1205
|
+
async mountCustomMiddleware() {
|
|
1206
|
+
if (!this.registerCustomMiddleware) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (this.openExpress) {
|
|
1210
|
+
await this.registerCustomMiddleware(this.openExpress, route_security_enum_1.DyNTS_RouteSecurity.open);
|
|
1211
|
+
}
|
|
1212
|
+
if (this.secureExpress) {
|
|
1213
|
+
await this.registerCustomMiddleware(this.secureExpress, route_security_enum_1.DyNTS_RouteSecurity.secure);
|
|
1214
|
+
}
|
|
1215
|
+
if (this.logSetup) {
|
|
1216
|
+
fsm_dynamo_1.DyFM_Log.log('\nCustom middleware registered (pre-static).');
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Ha getStaticClientSettings() visszaad beállításokat, a client static fájlok a '/' alatt
|
|
1221
|
+
* lesznek kiszolgálva (API route-ok után). SPA fallback opcionális (fallbackPath).
|
|
1222
|
+
* Asset cache (assetCacheMaxAge, assetCacheImmutable) és fallback cache (fallbackCacheMaxAge)
|
|
1223
|
+
* opcionálisak; ha nincs megadva fallbackCacheMaxAge, DyNTS_defaultFallbackCacheMaxAge (0) marad.
|
|
1224
|
+
*/
|
|
1225
|
+
async mountStaticClient() {
|
|
1226
|
+
const settings = this.getStaticClientSettings?.();
|
|
1227
|
+
if (!settings) {
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
const absoluteRoot = Path.isAbsolute(settings.root)
|
|
1231
|
+
? settings.root
|
|
1232
|
+
: Path.resolve(process.cwd(), settings.root);
|
|
1233
|
+
const hasAssetCache = settings.assetCacheMaxAge !== undefined || settings.assetCacheImmutable === true;
|
|
1234
|
+
const staticOptions = hasAssetCache && settings.assetCacheMaxAge !== undefined
|
|
1235
|
+
? {
|
|
1236
|
+
setHeaders: (res) => {
|
|
1237
|
+
const maxAge = settings.assetCacheMaxAge;
|
|
1238
|
+
const immutable = settings.assetCacheImmutable === true ? ', immutable' : '';
|
|
1239
|
+
res.setHeader('Cache-Control', `max-age=${maxAge}${immutable}`);
|
|
1240
|
+
},
|
|
1241
|
+
}
|
|
1242
|
+
: undefined;
|
|
1243
|
+
const staticMiddleware = staticOptions
|
|
1244
|
+
? Express.static(absoluteRoot, staticOptions)
|
|
1245
|
+
: Express.static(absoluteRoot);
|
|
1246
|
+
const fallbackMaxAge = settings.fallbackCacheMaxAge ?? default_fallback_cache_max_age_const_1.DyNTS_defaultFallbackCacheMaxAge;
|
|
1247
|
+
if (this.openExpress) {
|
|
1248
|
+
this.openExpress.use('/', staticMiddleware);
|
|
1249
|
+
if (settings.fallbackPath) {
|
|
1250
|
+
this.openExpress.get('*', (req, res) => {
|
|
1251
|
+
res.setHeader('Cache-Control', `max-age=${fallbackMaxAge}`);
|
|
1252
|
+
res.sendFile(settings.fallbackPath, { root: absoluteRoot });
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
else {
|
|
1256
|
+
this.openExpress.get('*', (req, res) => {
|
|
1257
|
+
res.status(404).type('html').send(default_not_found_page_const_1.DyNTS_defaultNotFoundPageHtml);
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
if (this.secureExpress) {
|
|
1262
|
+
this.secureExpress.use('/', staticMiddleware);
|
|
1263
|
+
if (settings.fallbackPath) {
|
|
1264
|
+
this.secureExpress.get('*', (req, res) => {
|
|
1265
|
+
res.setHeader('Cache-Control', `max-age=${fallbackMaxAge}`);
|
|
1266
|
+
res.sendFile(settings.fallbackPath, { root: absoluteRoot });
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
else {
|
|
1270
|
+
this.secureExpress.get('*', (req, res) => {
|
|
1271
|
+
res.status(404).type('html').send(default_not_found_page_const_1.DyNTS_defaultNotFoundPageHtml);
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (this.logSetup) {
|
|
1276
|
+
fsm_dynamo_1.DyFM_Log.log(`\nStatic client mounted at / (root: ${absoluteRoot})`);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
*
|
|
1281
|
+
*/
|
|
1282
|
+
setSecurity() {
|
|
1283
|
+
if (this.fnLogs && this.deepLog)
|
|
1284
|
+
fsm_dynamo_1.DyFM_Log.log('\nfn:. setSecurity');
|
|
1285
|
+
this._routingModules.forEach((module) => {
|
|
1286
|
+
if (!module.security) {
|
|
1287
|
+
fsm_dynamo_1.DyFM_Log.warn(`RoutingModule security is not set for ${module.route}\n`);
|
|
1288
|
+
}
|
|
1289
|
+
else if (!this._security) {
|
|
1290
|
+
this._security = module.security;
|
|
1291
|
+
}
|
|
1292
|
+
else if (this._security !== module.security) {
|
|
1293
|
+
this._security = route_security_enum_1.DyNTS_RouteSecurity.both;
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
if (!this._security) {
|
|
1297
|
+
let msg = `Could not set security for the server! (${this.security})`;
|
|
1298
|
+
msg += '\n RoutingModules:';
|
|
1299
|
+
this._routingModules.forEach((module) => {
|
|
1300
|
+
msg += `\n ${module.route} (security: ${module.security})`;
|
|
1301
|
+
});
|
|
1302
|
+
if (this._routingModules.length === 0) {
|
|
1303
|
+
msg += '\n - no RoutingModule found -\n';
|
|
1304
|
+
}
|
|
1305
|
+
fsm_dynamo_1.DyFM_Log.warn(msg);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
_getDefaultErrorSettings(fnName, error) {
|
|
1309
|
+
return {
|
|
1310
|
+
status: error?.___status ?? 500,
|
|
1311
|
+
message: error?.message ??
|
|
1312
|
+
error?._message ??
|
|
1313
|
+
`${fnName} was UNSUCCESSFUL (NTS)`,
|
|
1314
|
+
userMessage: error?.__userMessage ?? this.defaultErrorUserMsg,
|
|
1315
|
+
addECToUserMsg: !error?.__userMessage,
|
|
1316
|
+
issuerService: `${this?.constructor?.name}-DyNTS_App`,
|
|
1317
|
+
level: fsm_dynamo_1.DyFM_ErrorLevel.fatal,
|
|
1318
|
+
error: error,
|
|
1319
|
+
systemVersion: global_settings_const_1.DyNTS_global_settings.systemVersion,
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
exports.DyNTS_App = DyNTS_App;
|
|
1324
1324
|
//# sourceMappingURL=app.server.js.map
|