@contember/engine-http 2.2.0-alpha.1 → 2.2.0-alpha.11
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/CLAUDE.md +3 -1
- package/dist/development/index.cjs +28 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +27 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/MasterContainer.cjs +44 -19
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +44 -19
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/application/PanelApiMount.cjs +8 -0
- package/dist/development/src/application/PanelApiMount.cjs.map +1 -0
- package/dist/development/src/application/PanelApiMount.js +8 -0
- package/dist/development/src/application/PanelApiMount.js.map +1 -0
- package/dist/development/src/application/application.cjs +296 -69
- package/dist/development/src/application/application.cjs.map +1 -1
- package/dist/development/src/application/application.js +298 -71
- package/dist/development/src/application/application.js.map +1 -1
- package/dist/development/src/application/forceHttpOk.cjs +2 -9
- package/dist/development/src/application/forceHttpOk.cjs.map +1 -1
- package/dist/development/src/application/forceHttpOk.js +2 -9
- package/dist/development/src/application/forceHttpOk.js.map +1 -1
- package/dist/development/src/common/Authorizator.cjs +22 -19
- package/dist/development/src/common/Authorizator.cjs.map +1 -1
- package/dist/development/src/common/Authorizator.js +22 -19
- package/dist/development/src/common/Authorizator.js.map +1 -1
- package/dist/development/src/common/HttpResponse.cjs +5 -3
- package/dist/development/src/common/HttpResponse.cjs.map +1 -1
- package/dist/development/src/common/HttpResponse.js +5 -3
- package/dist/development/src/common/HttpResponse.js.map +1 -1
- package/dist/development/src/config/config.cjs +2 -1
- package/dist/development/src/config/config.cjs.map +1 -1
- package/dist/development/src/config/config.js +2 -1
- package/dist/development/src/config/config.js.map +1 -1
- package/dist/development/src/config/configSchema.cjs +71 -0
- package/dist/development/src/config/configSchema.cjs.map +1 -1
- package/dist/development/src/config/configSchema.js +71 -0
- package/dist/development/src/config/configSchema.js.map +1 -1
- package/dist/development/src/config/configTemplate.cjs +35 -1
- package/dist/development/src/config/configTemplate.cjs.map +1 -1
- package/dist/development/src/config/configTemplate.js +35 -1
- package/dist/development/src/config/configTemplate.js.map +1 -1
- package/dist/development/src/config/projectConfigResolver.cjs +1 -0
- package/dist/development/src/config/projectConfigResolver.cjs.map +1 -1
- package/dist/development/src/config/projectConfigResolver.js +2 -1
- package/dist/development/src/config/projectConfigResolver.js.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +30 -4
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +30 -4
- package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.cjs +44 -16
- package/dist/development/src/content/ContentApiSpecificCache.cjs.map +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.js +44 -16
- package/dist/development/src/content/ContentApiSpecificCache.js.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.cjs +2 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.js +2 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.cjs +26 -3
- package/dist/development/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.js +26 -3
- package/dist/development/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/development/src/graphql/execution.cjs +19 -4
- package/dist/development/src/graphql/execution.cjs.map +1 -1
- package/dist/development/src/graphql/execution.js +19 -4
- package/dist/development/src/graphql/execution.js.map +1 -1
- package/dist/development/src/misc/HomepageMiddlewareFactory.cjs +1 -0
- package/dist/development/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/misc/HomepageMiddlewareFactory.js +1 -0
- package/dist/development/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/development/src/project/ProjectContainer.cjs +1 -0
- package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainer.js +1 -0
- package/dist/development/src/project/ProjectContainer.js.map +1 -1
- package/dist/development/src/project-common/ProjectContextResolver.cjs +1 -0
- package/dist/development/src/project-common/ProjectContextResolver.cjs.map +1 -1
- package/dist/development/src/project-common/ProjectContextResolver.js +1 -0
- package/dist/development/src/project-common/ProjectContextResolver.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +27 -22
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +27 -22
- package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupResolver.cjs +1 -0
- package/dist/development/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupResolver.js +1 -0
- package/dist/development/src/projectGroup/ProjectGroupResolver.js.map +1 -1
- package/dist/development/src/prometheus/dbMetrics.cjs +4 -1
- package/dist/development/src/prometheus/dbMetrics.cjs.map +1 -1
- package/dist/development/src/prometheus/dbMetrics.js +5 -2
- package/dist/development/src/prometheus/dbMetrics.js.map +1 -1
- package/dist/development/src/system/SystemApiMiddlewareFactory.cjs +1 -0
- package/dist/development/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemApiMiddlewareFactory.js +1 -0
- package/dist/development/src/system/SystemApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/telemetry/FilteringSpanProcessor.cjs +15 -0
- package/dist/development/src/telemetry/FilteringSpanProcessor.cjs.map +1 -0
- package/dist/development/src/telemetry/FilteringSpanProcessor.js +15 -0
- package/dist/development/src/telemetry/FilteringSpanProcessor.js.map +1 -0
- package/dist/development/src/telemetry/ProjectGroupContainerTelemetryHook.cjs +59 -0
- package/dist/development/src/telemetry/ProjectGroupContainerTelemetryHook.cjs.map +1 -0
- package/dist/development/src/telemetry/ProjectGroupContainerTelemetryHook.js +59 -0
- package/dist/development/src/telemetry/ProjectGroupContainerTelemetryHook.js.map +1 -0
- package/dist/development/src/telemetry/TelemetryFactory.cjs +87 -0
- package/dist/development/src/telemetry/TelemetryFactory.cjs.map +1 -0
- package/dist/development/src/telemetry/TelemetryFactory.js +87 -0
- package/dist/development/src/telemetry/TelemetryFactory.js.map +1 -0
- package/dist/development/src/telemetry/incomingTrace.cjs +32 -0
- package/dist/development/src/telemetry/incomingTrace.cjs.map +1 -0
- package/dist/development/src/telemetry/incomingTrace.js +32 -0
- package/dist/development/src/telemetry/incomingTrace.js.map +1 -0
- package/dist/development/src/telemetry/sqlSpans.cjs +59 -0
- package/dist/development/src/telemetry/sqlSpans.cjs.map +1 -0
- package/dist/development/src/telemetry/sqlSpans.js +59 -0
- package/dist/development/src/telemetry/sqlSpans.js.map +1 -0
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs +1 -0
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js +1 -0
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs +13 -14
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js +13 -14
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/testing/TestTransactions.cjs +21 -11
- package/dist/development/src/testing/TestTransactions.cjs.map +1 -1
- package/dist/development/src/testing/TestTransactions.js +21 -11
- package/dist/development/src/testing/TestTransactions.js.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs +1 -0
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.js +1 -0
- package/dist/development/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs +1 -0
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.js +1 -0
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.cjs +1 -0
- package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.js +1 -0
- package/dist/development/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/development/src/utils/remoteAddress.cjs +9 -1
- package/dist/development/src/utils/remoteAddress.cjs.map +1 -1
- package/dist/development/src/utils/remoteAddress.js +10 -2
- package/dist/development/src/utils/remoteAddress.js.map +1 -1
- package/dist/development/src/utils/sentry.cjs +4 -1
- package/dist/development/src/utils/sentry.cjs.map +1 -1
- package/dist/development/src/utils/sentry.js +4 -1
- package/dist/development/src/utils/sentry.js.map +1 -1
- package/dist/development/src/utils/serverTermination.cjs +21 -3
- package/dist/development/src/utils/serverTermination.cjs.map +1 -1
- package/dist/development/src/utils/serverTermination.js +21 -3
- package/dist/development/src/utils/serverTermination.js.map +1 -1
- package/dist/development/src/utils/truthyHeader.cjs +13 -0
- package/dist/development/src/utils/truthyHeader.cjs.map +1 -0
- package/dist/development/src/utils/truthyHeader.js +13 -0
- package/dist/development/src/utils/truthyHeader.js.map +1 -0
- package/dist/production/index.cjs +28 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +27 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +44 -19
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +44 -19
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/application/PanelApiMount.cjs +8 -0
- package/dist/production/src/application/PanelApiMount.cjs.map +1 -0
- package/dist/production/src/application/PanelApiMount.js +8 -0
- package/dist/production/src/application/PanelApiMount.js.map +1 -0
- package/dist/production/src/application/application.cjs +296 -69
- package/dist/production/src/application/application.cjs.map +1 -1
- package/dist/production/src/application/application.js +298 -71
- package/dist/production/src/application/application.js.map +1 -1
- package/dist/production/src/application/forceHttpOk.cjs +2 -9
- package/dist/production/src/application/forceHttpOk.cjs.map +1 -1
- package/dist/production/src/application/forceHttpOk.js +2 -9
- package/dist/production/src/application/forceHttpOk.js.map +1 -1
- package/dist/production/src/common/Authorizator.cjs +22 -19
- package/dist/production/src/common/Authorizator.cjs.map +1 -1
- package/dist/production/src/common/Authorizator.js +22 -19
- package/dist/production/src/common/Authorizator.js.map +1 -1
- package/dist/production/src/common/HttpResponse.cjs +5 -3
- package/dist/production/src/common/HttpResponse.cjs.map +1 -1
- package/dist/production/src/common/HttpResponse.js +5 -3
- package/dist/production/src/common/HttpResponse.js.map +1 -1
- package/dist/production/src/config/config.cjs +2 -1
- package/dist/production/src/config/config.cjs.map +1 -1
- package/dist/production/src/config/config.js +2 -1
- package/dist/production/src/config/config.js.map +1 -1
- package/dist/production/src/config/configSchema.cjs +71 -0
- package/dist/production/src/config/configSchema.cjs.map +1 -1
- package/dist/production/src/config/configSchema.js +71 -0
- package/dist/production/src/config/configSchema.js.map +1 -1
- package/dist/production/src/config/configTemplate.cjs +35 -1
- package/dist/production/src/config/configTemplate.cjs.map +1 -1
- package/dist/production/src/config/configTemplate.js +35 -1
- package/dist/production/src/config/configTemplate.js.map +1 -1
- package/dist/production/src/config/projectConfigResolver.cjs +1 -0
- package/dist/production/src/config/projectConfigResolver.cjs.map +1 -1
- package/dist/production/src/config/projectConfigResolver.js +2 -1
- package/dist/production/src/config/projectConfigResolver.js.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +30 -4
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +30 -4
- package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.cjs +44 -16
- package/dist/production/src/content/ContentApiSpecificCache.cjs.map +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.js +44 -16
- package/dist/production/src/content/ContentApiSpecificCache.js.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.cjs +2 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.js +2 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.cjs +26 -3
- package/dist/production/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.js +26 -3
- package/dist/production/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/production/src/graphql/execution.cjs +19 -4
- package/dist/production/src/graphql/execution.cjs.map +1 -1
- package/dist/production/src/graphql/execution.js +19 -4
- package/dist/production/src/graphql/execution.js.map +1 -1
- package/dist/production/src/misc/HomepageMiddlewareFactory.cjs +1 -0
- package/dist/production/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/misc/HomepageMiddlewareFactory.js +1 -0
- package/dist/production/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/production/src/project/ProjectContainer.cjs +1 -0
- package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainer.js +1 -0
- package/dist/production/src/project/ProjectContainer.js.map +1 -1
- package/dist/production/src/project-common/ProjectContextResolver.cjs +1 -0
- package/dist/production/src/project-common/ProjectContextResolver.cjs.map +1 -1
- package/dist/production/src/project-common/ProjectContextResolver.js +1 -0
- package/dist/production/src/project-common/ProjectContextResolver.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +27 -22
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +27 -22
- package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupResolver.cjs +1 -0
- package/dist/production/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupResolver.js +1 -0
- package/dist/production/src/projectGroup/ProjectGroupResolver.js.map +1 -1
- package/dist/production/src/prometheus/dbMetrics.cjs +4 -1
- package/dist/production/src/prometheus/dbMetrics.cjs.map +1 -1
- package/dist/production/src/prometheus/dbMetrics.js +5 -2
- package/dist/production/src/prometheus/dbMetrics.js.map +1 -1
- package/dist/production/src/system/SystemApiMiddlewareFactory.cjs +1 -0
- package/dist/production/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemApiMiddlewareFactory.js +1 -0
- package/dist/production/src/system/SystemApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/telemetry/FilteringSpanProcessor.cjs +15 -0
- package/dist/production/src/telemetry/FilteringSpanProcessor.cjs.map +1 -0
- package/dist/production/src/telemetry/FilteringSpanProcessor.js +15 -0
- package/dist/production/src/telemetry/FilteringSpanProcessor.js.map +1 -0
- package/dist/production/src/telemetry/ProjectGroupContainerTelemetryHook.cjs +59 -0
- package/dist/production/src/telemetry/ProjectGroupContainerTelemetryHook.cjs.map +1 -0
- package/dist/production/src/telemetry/ProjectGroupContainerTelemetryHook.js +59 -0
- package/dist/production/src/telemetry/ProjectGroupContainerTelemetryHook.js.map +1 -0
- package/dist/production/src/telemetry/TelemetryFactory.cjs +87 -0
- package/dist/production/src/telemetry/TelemetryFactory.cjs.map +1 -0
- package/dist/production/src/telemetry/TelemetryFactory.js +87 -0
- package/dist/production/src/telemetry/TelemetryFactory.js.map +1 -0
- package/dist/production/src/telemetry/incomingTrace.cjs +32 -0
- package/dist/production/src/telemetry/incomingTrace.cjs.map +1 -0
- package/dist/production/src/telemetry/incomingTrace.js +32 -0
- package/dist/production/src/telemetry/incomingTrace.js.map +1 -0
- package/dist/production/src/telemetry/sqlSpans.cjs +59 -0
- package/dist/production/src/telemetry/sqlSpans.cjs.map +1 -0
- package/dist/production/src/telemetry/sqlSpans.js +59 -0
- package/dist/production/src/telemetry/sqlSpans.js.map +1 -0
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs +1 -0
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js +1 -0
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs +13 -14
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js +13 -14
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/testing/TestTransactions.cjs +21 -11
- package/dist/production/src/testing/TestTransactions.cjs.map +1 -1
- package/dist/production/src/testing/TestTransactions.js +21 -11
- package/dist/production/src/testing/TestTransactions.js.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs +1 -0
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.js +1 -0
- package/dist/production/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs +1 -0
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.js +1 -0
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.cjs +1 -0
- package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.js +1 -0
- package/dist/production/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/production/src/utils/remoteAddress.cjs +9 -1
- package/dist/production/src/utils/remoteAddress.cjs.map +1 -1
- package/dist/production/src/utils/remoteAddress.js +10 -2
- package/dist/production/src/utils/remoteAddress.js.map +1 -1
- package/dist/production/src/utils/sentry.cjs +4 -1
- package/dist/production/src/utils/sentry.cjs.map +1 -1
- package/dist/production/src/utils/sentry.js +4 -1
- package/dist/production/src/utils/sentry.js.map +1 -1
- package/dist/production/src/utils/serverTermination.cjs +21 -3
- package/dist/production/src/utils/serverTermination.cjs.map +1 -1
- package/dist/production/src/utils/serverTermination.js +21 -3
- package/dist/production/src/utils/serverTermination.js.map +1 -1
- package/dist/production/src/utils/truthyHeader.cjs +13 -0
- package/dist/production/src/utils/truthyHeader.cjs.map +1 -0
- package/dist/production/src/utils/truthyHeader.js +13 -0
- package/dist/production/src/utils/truthyHeader.js.map +1 -0
- package/dist/tests/cases/integration/requestMemoryBudget.test.d.ts +2 -0
- package/dist/tests/cases/integration/requestMemoryBudget.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/applicationShutdown.test.d.ts +2 -0
- package/dist/tests/cases/unit/applicationShutdown.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/contentApiSpecificCacheLimit.test.d.ts +2 -0
- package/dist/tests/cases/unit/contentApiSpecificCacheLimit.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/forcePrimary.test.d.ts +2 -0
- package/dist/tests/cases/unit/forcePrimary.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/graphQlSchemaFactory.test.d.ts +2 -0
- package/dist/tests/cases/unit/graphQlSchemaFactory.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/incomingTrace.test.d.ts +2 -0
- package/dist/tests/cases/unit/incomingTrace.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/requestMemoryBudget.test.d.ts +2 -0
- package/dist/tests/cases/unit/requestMemoryBudget.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/requestTracing.test.d.ts +2 -0
- package/dist/tests/cases/unit/requestTracing.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/serverTermination.fixture.d.ts +2 -0
- package/dist/tests/cases/unit/serverTermination.fixture.d.ts.map +1 -0
- package/dist/tests/cases/unit/serverTermination.test.d.ts +2 -0
- package/dist/tests/cases/unit/serverTermination.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/spanFiltering.test.d.ts +2 -0
- package/dist/tests/cases/unit/spanFiltering.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/sqlSpans.test.d.ts +2 -0
- package/dist/tests/cases/unit/sqlSpans.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/telemetryConfig.test.d.ts +2 -0
- package/dist/tests/cases/unit/telemetryConfig.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/timerFacade.test.d.ts +2 -0
- package/dist/tests/cases/unit/timerFacade.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +66 -6
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/application/PanelApiMount.d.ts +29 -0
- package/dist/types/application/PanelApiMount.d.ts.map +1 -0
- package/dist/types/application/application.d.ts +19 -1
- package/dist/types/application/application.d.ts.map +1 -1
- package/dist/types/application/forceHttpOk.d.ts.map +1 -1
- package/dist/types/application/index.d.ts +1 -0
- package/dist/types/application/index.d.ts.map +1 -1
- package/dist/types/bootstrap/Initializer.d.ts.map +1 -1
- package/dist/types/common/Authorizator.d.ts +9 -1
- package/dist/types/common/Authorizator.d.ts.map +1 -1
- package/dist/types/common/HttpResponse.d.ts +6 -2
- package/dist/types/common/HttpResponse.d.ts.map +1 -1
- package/dist/types/common/ModuleInfoMiddleware.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +2 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/config/config.d.ts +3 -1
- package/dist/types/config/config.d.ts.map +1 -1
- package/dist/types/config/configSchema.d.ts +358 -11
- package/dist/types/config/configSchema.d.ts.map +1 -1
- package/dist/types/config/configTemplate.d.ts.map +1 -1
- package/dist/types/config/projectConfigResolver.d.ts +1 -0
- package/dist/types/config/projectConfigResolver.d.ts.map +1 -1
- package/dist/types/config/tenantConfigResolver.d.ts.map +1 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts +4 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentApiSpecificCache.d.ts +5 -0
- package/dist/types/content/ContentApiSpecificCache.d.ts.map +1 -1
- package/dist/types/content/ContentGraphqlContext.d.ts +2 -0
- package/dist/types/content/ContentGraphqlContext.d.ts.map +1 -1
- package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentSchemaResolver.d.ts.map +1 -1
- package/dist/types/content/GraphQLSchemaContributor.d.ts +4 -0
- package/dist/types/content/GraphQLSchemaContributor.d.ts.map +1 -1
- package/dist/types/content/GraphQlSchemaFactory.d.ts +2 -0
- package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/types/content/NotModifiedChecker.d.ts.map +1 -1
- package/dist/types/content/ProjectMembershipFetcher.d.ts.map +1 -1
- package/dist/types/content/ProjectMembershipResolver.d.ts.map +1 -1
- package/dist/types/graphql/dbQueriesListener.d.ts.map +1 -1
- package/dist/types/graphql/execution.d.ts +4 -1
- package/dist/types/graphql/execution.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/project/ProjectContainer.d.ts.map +1 -1
- package/dist/types/project/ProjectContainerResolver.d.ts.map +1 -1
- package/dist/types/project/ProjectContainerStore.d.ts.map +1 -1
- package/dist/types/project/ProjectDatabaseMetadataResolver.d.ts.map +1 -1
- package/dist/types/project/ProjectInitializer.d.ts.map +1 -1
- package/dist/types/project/ProjectSchemaResolver.d.ts.map +1 -1
- package/dist/types/project-common/ProjectContextResolver.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupContainerResolver.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupResolver.d.ts.map +1 -1
- package/dist/types/prometheus/CollectHttpMetricsMiddelware.d.ts.map +1 -1
- package/dist/types/prometheus/CustomMetric.d.ts.map +1 -1
- package/dist/types/prometheus/ProjectGroupContainerMetricsHook.d.ts.map +1 -1
- package/dist/types/prometheus/PrometheusRegistryFactory.d.ts.map +1 -1
- package/dist/types/prometheus/ShowMetricsMiddleware.d.ts.map +1 -1
- package/dist/types/prometheus/contemberEngineInfoMetric.d.ts.map +1 -1
- package/dist/types/prometheus/dbMetrics.d.ts.map +1 -1
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/system/SystemApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLContextFactory.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/telemetry/FilteringSpanProcessor.d.ts +8 -0
- package/dist/types/telemetry/FilteringSpanProcessor.d.ts.map +1 -0
- package/dist/types/telemetry/ProjectGroupContainerTelemetryHook.d.ts +18 -0
- package/dist/types/telemetry/ProjectGroupContainerTelemetryHook.d.ts.map +1 -0
- package/dist/types/telemetry/TelemetryFactory.d.ts +19 -0
- package/dist/types/telemetry/TelemetryFactory.d.ts.map +1 -0
- package/dist/types/telemetry/incomingTrace.d.ts +18 -0
- package/dist/types/telemetry/incomingTrace.d.ts.map +1 -0
- package/dist/types/telemetry/index.d.ts +6 -0
- package/dist/types/telemetry/index.d.ts.map +1 -0
- package/dist/types/telemetry/sqlSpans.d.ts +16 -0
- package/dist/types/telemetry/sqlSpans.d.ts.map +1 -0
- package/dist/types/tenant/OidcBackchannelLogoutMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/testing/TestTransactions.d.ts.map +1 -1
- package/dist/types/transfer/Command.d.ts +5 -5
- package/dist/types/transfer/Command.d.ts.map +1 -1
- package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportApiControllerFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportExecutor.d.ts.map +1 -1
- package/dist/types/transfer/ImportApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/transfer/ImportExecutor.d.ts.map +1 -1
- package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/CryptoWrapper.d.ts +1 -1
- package/dist/types/utils/CryptoWrapper.d.ts.map +1 -1
- package/dist/types/utils/memoizeObject.d.ts.map +1 -1
- package/dist/types/utils/remoteAddress.d.ts +1 -0
- package/dist/types/utils/remoteAddress.d.ts.map +1 -1
- package/dist/types/utils/sentry.d.ts.map +1 -1
- package/dist/types/utils/serverStartup.d.ts +1 -0
- package/dist/types/utils/serverStartup.d.ts.map +1 -1
- package/dist/types/utils/serverTermination.d.ts +13 -1
- package/dist/types/utils/serverTermination.d.ts.map +1 -1
- package/dist/types/utils/strings.d.ts.map +1 -1
- package/dist/types/utils/truthyHeader.d.ts +3 -0
- package/dist/types/utils/truthyHeader.d.ts.map +1 -0
- package/dist/types/workers/ApplicationWorkerManager.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/MasterContainer.ts +50 -16
- package/src/application/PanelApiMount.ts +33 -0
- package/src/application/application.ts +315 -76
- package/src/application/forceHttpOk.ts +2 -10
- package/src/application/index.ts +1 -0
- package/src/common/Authorizator.ts +41 -21
- package/src/common/HttpResponse.ts +4 -0
- package/src/common/index.ts +2 -0
- package/src/config/config.ts +4 -1
- package/src/config/configSchema.ts +72 -0
- package/src/config/configTemplate.ts +34 -0
- package/src/config/projectConfigResolver.ts +1 -1
- package/src/content/ContentApiControllerFactory.ts +32 -4
- package/src/content/ContentApiSpecificCache.ts +56 -17
- package/src/content/ContentGraphqlContext.ts +2 -0
- package/src/content/ContentQueryHandlerFactory.ts +1 -0
- package/src/content/GraphQLSchemaContributor.ts +4 -0
- package/src/content/GraphQlSchemaFactory.ts +29 -3
- package/src/graphql/execution.ts +27 -4
- package/src/index.ts +2 -0
- package/src/projectGroup/ProjectGroupContainer.ts +28 -24
- package/src/prometheus/dbMetrics.ts +5 -2
- package/src/telemetry/FilteringSpanProcessor.ts +22 -0
- package/src/telemetry/ProjectGroupContainerTelemetryHook.ts +67 -0
- package/src/telemetry/TelemetryFactory.ts +118 -0
- package/src/telemetry/incomingTrace.ts +47 -0
- package/src/telemetry/index.ts +5 -0
- package/src/telemetry/sqlSpans.ts +76 -0
- package/src/tenant/TenantApiMiddlewareFactory.ts +14 -14
- package/src/testing/TestTransactions.ts +21 -11
- package/src/tsconfig.json +1 -0
- package/src/utils/remoteAddress.ts +9 -2
- package/src/utils/sentry.ts +5 -0
- package/src/utils/serverTermination.ts +41 -3
- package/src/utils/truthyHeader.ts +12 -0
- package/tests/cases/integration/requestMemoryBudget.test.ts +88 -0
- package/tests/cases/unit/applicationShutdown.test.ts +149 -0
- package/tests/cases/unit/contentApiSpecificCache.tst.js +22 -0
- package/tests/cases/unit/contentApiSpecificCacheLimit.test.ts +63 -0
- package/tests/cases/unit/forcePrimary.test.ts +295 -0
- package/tests/cases/unit/graphQlSchemaFactory.test.ts +87 -0
- package/tests/cases/unit/incomingTrace.test.ts +100 -0
- package/tests/cases/unit/remoteAddress.test.ts +13 -1
- package/tests/cases/unit/requestMemoryBudget.test.ts +172 -0
- package/tests/cases/unit/requestTracing.test.ts +224 -0
- package/tests/cases/unit/serverConfig.test.ts +35 -0
- package/tests/cases/unit/serverTermination.fixture.ts +13 -0
- package/tests/cases/unit/serverTermination.test.ts +97 -0
- package/tests/cases/unit/spanFiltering.test.ts +71 -0
- package/tests/cases/unit/sqlSpans.test.ts +198 -0
- package/tests/cases/unit/telemetryConfig.test.ts +186 -0
- package/tests/cases/unit/timerFacade.test.ts +78 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { pathToRegexp } from "path-to-regexp";
|
|
2
2
|
import { HttpErrorResponse, HttpResponse } from "../common/HttpResponse.js";
|
|
3
3
|
import "ipaddr.js";
|
|
4
|
+
import "@contember/engine-tenant-api";
|
|
4
5
|
import Koa from "koa";
|
|
5
6
|
import * as http from "node:http";
|
|
6
|
-
import { WebSocketServer } from "ws";
|
|
7
|
+
import { WebSocketServer, WebSocket } from "ws";
|
|
7
8
|
import { FingerCrossedLoggerHandler } from "@contember/logger";
|
|
8
9
|
import koaCompress from "koa-compress";
|
|
9
10
|
import bodyParser from "koa-bodyparser";
|
|
@@ -14,16 +15,20 @@ import { cpuUsage, memoryUsage } from "node:process";
|
|
|
14
15
|
import { performance } from "node:perf_hooks";
|
|
15
16
|
import { getClientIP } from "../utils/remoteAddress.js";
|
|
16
17
|
import { shouldForceHttpOk, isForceHttpOkRequested } from "./forceHttpOk.js";
|
|
18
|
+
import { noopTracer, INVALID_TRACE_ID, withSpanContext } from "@contember/telemetry";
|
|
19
|
+
import { resolveIncomingSpanContext } from "../telemetry/incomingTrace.js";
|
|
17
20
|
var __defProp = Object.defineProperty;
|
|
18
21
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
22
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
23
|
+
const websocketCloseTimeoutMs = 5e3;
|
|
20
24
|
class Application {
|
|
21
|
-
constructor(projectGroupResolver, serverConfig, debugMode, version, logger) {
|
|
25
|
+
constructor(projectGroupResolver, serverConfig, debugMode, version, logger, tracer = noopTracer) {
|
|
22
26
|
this.projectGroupResolver = projectGroupResolver;
|
|
23
27
|
this.serverConfig = serverConfig;
|
|
24
28
|
this.debugMode = debugMode;
|
|
25
29
|
this.version = version;
|
|
26
30
|
this.logger = logger;
|
|
31
|
+
this.tracer = tracer;
|
|
27
32
|
__publicField(this, "middlewares", []);
|
|
28
33
|
__publicField(this, "routes", []);
|
|
29
34
|
__publicField(this, "internalRoutes", []);
|
|
@@ -31,10 +36,14 @@ class Application {
|
|
|
31
36
|
__publicField(this, "suppressAccessLog");
|
|
32
37
|
__publicField(this, "trustedProxies");
|
|
33
38
|
__publicField(this, "forceHttpOkEnabled");
|
|
39
|
+
__publicField(this, "acceptIncomingTrace");
|
|
40
|
+
__publicField(this, "traceIdResponseHeader");
|
|
34
41
|
const suppressAccessLogRaw = serverConfig.http?.suppressAccessLog;
|
|
35
42
|
this.suppressAccessLog = suppressAccessLogRaw === true ? true : suppressAccessLogRaw ? new RegExp(suppressAccessLogRaw) : false;
|
|
36
43
|
this.trustedProxies = serverConfig.http?.trustedProxies ?? [];
|
|
37
44
|
this.forceHttpOkEnabled = serverConfig.http?.responseStatusHeader ?? true;
|
|
45
|
+
this.acceptIncomingTrace = serverConfig.telemetry?.traces?.acceptIncoming ?? "trusted-proxies";
|
|
46
|
+
this.traceIdResponseHeader = serverConfig.telemetry?.traces?.traceIdResponseHeader ?? false;
|
|
38
47
|
}
|
|
39
48
|
addMiddleware(middleware) {
|
|
40
49
|
this.middlewares.push(middleware);
|
|
@@ -43,6 +52,7 @@ class Application {
|
|
|
43
52
|
this.routes.push({
|
|
44
53
|
module,
|
|
45
54
|
controller,
|
|
55
|
+
mask,
|
|
46
56
|
match: createRequestMatcher(mask)
|
|
47
57
|
});
|
|
48
58
|
}
|
|
@@ -50,6 +60,7 @@ class Application {
|
|
|
50
60
|
this.internalRoutes.push({
|
|
51
61
|
module,
|
|
52
62
|
controller,
|
|
63
|
+
mask,
|
|
53
64
|
match: createRequestMatcher(mask)
|
|
54
65
|
});
|
|
55
66
|
}
|
|
@@ -57,12 +68,22 @@ class Application {
|
|
|
57
68
|
this.websocketRoutes.push({
|
|
58
69
|
module,
|
|
59
70
|
controller,
|
|
71
|
+
mask,
|
|
60
72
|
match: createRequestMatcher(mask)
|
|
61
73
|
});
|
|
62
74
|
}
|
|
63
75
|
async listen() {
|
|
64
76
|
const koa = new Koa();
|
|
65
77
|
const wss = new WebSocketServer({ noServer: true });
|
|
78
|
+
let closing = false;
|
|
79
|
+
koa.use(async (ctx, next) => {
|
|
80
|
+
if (closing) {
|
|
81
|
+
ctx.status = 503;
|
|
82
|
+
ctx.set("Connection", "close");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
await next();
|
|
86
|
+
});
|
|
66
87
|
for (const middleware of this.middlewares) {
|
|
67
88
|
koa.use(middleware);
|
|
68
89
|
}
|
|
@@ -72,18 +93,44 @@ class Application {
|
|
|
72
93
|
koa.use(bodyParser({
|
|
73
94
|
jsonLimit: this.serverConfig.http?.requestBodySize || "1mb"
|
|
74
95
|
}));
|
|
75
|
-
koa.use(corsMiddleware());
|
|
96
|
+
koa.use(corsMiddleware({ exposeHeaders: ["X-Contember-Mutation"] }));
|
|
76
97
|
const versionMatch = this.version?.match(/^(0\.\d+|\d+)/);
|
|
77
98
|
const versionSimplified = versionMatch?.[1] ?? "unknown";
|
|
78
99
|
koa.use(async (ctx) => {
|
|
79
100
|
ctx.response.set("X-Powered-By", `Contember ${versionSimplified}` + (this.debugMode ? "-dev" : ""));
|
|
80
101
|
await this.handleHttpRequest(ctx);
|
|
81
102
|
});
|
|
82
|
-
const
|
|
103
|
+
const activeHttpRequests = /* @__PURE__ */ new Set();
|
|
104
|
+
const handleHttpRequest = koa.callback();
|
|
105
|
+
const server = http.createServer((request, response) => {
|
|
106
|
+
if (closing) {
|
|
107
|
+
handleHttpRequest(request, response);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
let resolveRequest = () => {
|
|
111
|
+
};
|
|
112
|
+
const completed = new Promise((resolve) => {
|
|
113
|
+
resolveRequest = resolve;
|
|
114
|
+
});
|
|
115
|
+
activeHttpRequests.add(completed);
|
|
116
|
+
const complete = () => {
|
|
117
|
+
response.off("finish", complete);
|
|
118
|
+
response.off("close", complete);
|
|
119
|
+
activeHttpRequests.delete(completed);
|
|
120
|
+
resolveRequest();
|
|
121
|
+
};
|
|
122
|
+
response.once("finish", complete);
|
|
123
|
+
response.once("close", complete);
|
|
124
|
+
handleHttpRequest(request, response);
|
|
125
|
+
});
|
|
83
126
|
const abortController = new AbortController();
|
|
84
127
|
const wsRequests = [];
|
|
85
128
|
server.on("upgrade", (req, socket, head) => {
|
|
86
|
-
|
|
129
|
+
if (closing) {
|
|
130
|
+
this.sendRawHttpResponse(socket, new HttpErrorResponse(503, "Server is shutting down"));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
wsRequests.push(this.handleWebsocketRequest(wss, abortController.signal, req, socket, head).finally(() => socket.destroy()));
|
|
87
134
|
});
|
|
88
135
|
await new Promise((resolve) => {
|
|
89
136
|
server.listen(this.serverConfig.port, () => resolve());
|
|
@@ -91,14 +138,28 @@ class Application {
|
|
|
91
138
|
return {
|
|
92
139
|
server,
|
|
93
140
|
close: async () => {
|
|
141
|
+
closing = true;
|
|
94
142
|
abortController.abort();
|
|
95
|
-
await Promise.all(wsRequests);
|
|
96
|
-
|
|
143
|
+
await Promise.all([...wsRequests, ...activeHttpRequests]);
|
|
144
|
+
if (process.versions.bun !== void 0) {
|
|
145
|
+
server.closeAllConnections();
|
|
146
|
+
} else {
|
|
147
|
+
server.closeIdleConnections();
|
|
148
|
+
}
|
|
149
|
+
if (server.listening) {
|
|
150
|
+
await new Promise(
|
|
151
|
+
(resolve) => server.close((error) => {
|
|
152
|
+
if (error) {
|
|
153
|
+
this.logger.error(error);
|
|
154
|
+
}
|
|
155
|
+
resolve();
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
}
|
|
97
159
|
}
|
|
98
160
|
};
|
|
99
161
|
}
|
|
100
162
|
async handleWebsocketRequest(wss, abortSignal, req, socket, head) {
|
|
101
|
-
let webSocketContext = null;
|
|
102
163
|
let requestLogger = this.logger;
|
|
103
164
|
const { timer, send: sendTimer } = this.createTimer();
|
|
104
165
|
const clientIp = getClientIP(req, this.trustedProxies);
|
|
@@ -108,50 +169,94 @@ class Application {
|
|
|
108
169
|
if (!matchedRequest) {
|
|
109
170
|
throw new HttpErrorResponse(404, "Route not found");
|
|
110
171
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
user: authResult?.identityId
|
|
120
|
-
});
|
|
121
|
-
const effectiveClientIp = authResult?.clientIp ?? clientIp;
|
|
122
|
-
const ws = await new Promise(
|
|
123
|
-
(resolve) => wss.handleUpgrade(req, socket, head, (ws2, request) => {
|
|
124
|
-
resolve(ws2);
|
|
125
|
-
})
|
|
126
|
-
);
|
|
127
|
-
const wsEstablished = performance.now();
|
|
128
|
-
webSocketContext = {
|
|
129
|
-
ws,
|
|
130
|
-
abortSignal,
|
|
131
|
-
logger: requestLogger,
|
|
132
|
-
timer,
|
|
133
|
-
url,
|
|
134
|
-
request: req,
|
|
135
|
-
clientIp: effectiveClientIp,
|
|
136
|
-
authResult,
|
|
137
|
-
params: matchedRequest.params,
|
|
138
|
-
projectGroup: groupContainer
|
|
139
|
-
};
|
|
140
|
-
await matchedRequest.controller(webSocketContext);
|
|
141
|
-
requestLogger.debug("Websocket connection established");
|
|
142
|
-
ws.on("error", (e) => {
|
|
143
|
-
requestLogger.error(e, {
|
|
144
|
-
websocketOpenMs: performance.now() - wsEstablished
|
|
172
|
+
const established = await this.withIncomingTrace(req, async () => {
|
|
173
|
+
const span = this.tracer.startSpan(`WS ${matchedRequest.mask}`, {
|
|
174
|
+
kind: "server",
|
|
175
|
+
attributes: {
|
|
176
|
+
"http.request.method": req.method ?? "GET",
|
|
177
|
+
"url.path": url.pathname,
|
|
178
|
+
"contember.module": matchedRequest.module
|
|
179
|
+
}
|
|
145
180
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
181
|
+
return await this.tracer.withSpan(span, async () => {
|
|
182
|
+
const pendingWork2 = [];
|
|
183
|
+
try {
|
|
184
|
+
requestLogger = this.createRequestLogger(req, void 0, matchedRequest.module, clientIp, span.context);
|
|
185
|
+
const groupContainer = await this.projectGroupResolver.resolveContainer({ request: req });
|
|
186
|
+
requestLogger = requestLogger.child({ projectGroup: groupContainer.slug });
|
|
187
|
+
span.setAttribute("contember.project_group", groupContainer.slug ?? "unknown");
|
|
188
|
+
if (matchedRequest.params.projectSlug !== void 0) {
|
|
189
|
+
span.setAttribute("contember.project", matchedRequest.params.projectSlug);
|
|
190
|
+
}
|
|
191
|
+
const authResult = await groupContainer.authenticator.authenticate({ request: req, timer, clientIp });
|
|
192
|
+
requestLogger.debug("User authenticated", { authResult });
|
|
193
|
+
requestLogger = requestLogger.child({ user: authResult?.identityId });
|
|
194
|
+
if (authResult) {
|
|
195
|
+
span.setAttribute("contember.identity_id", authResult.identityId);
|
|
196
|
+
}
|
|
197
|
+
if (abortSignal.aborted) {
|
|
198
|
+
throw new HttpErrorResponse(503, "Server is shutting down");
|
|
199
|
+
}
|
|
200
|
+
const ws = await new Promise((resolve) => wss.handleUpgrade(req, socket, head, (ws2) => resolve(ws2)));
|
|
201
|
+
const establishedAt2 = performance.now();
|
|
202
|
+
const closed2 = new Promise((resolve) => ws.once("close", () => resolve()));
|
|
203
|
+
ws.on("error", (e) => {
|
|
204
|
+
requestLogger.error(e, {
|
|
205
|
+
websocketOpenMs: performance.now() - establishedAt2
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
span.setAttribute("http.response.status_code", 101);
|
|
209
|
+
if (abortSignal.aborted) {
|
|
210
|
+
await this.closeWebsocket(ws);
|
|
211
|
+
return void 0;
|
|
212
|
+
}
|
|
213
|
+
const context = {
|
|
214
|
+
ws,
|
|
215
|
+
abortSignal,
|
|
216
|
+
logger: requestLogger,
|
|
217
|
+
timer,
|
|
218
|
+
tracer: this.tracer,
|
|
219
|
+
url,
|
|
220
|
+
request: req,
|
|
221
|
+
clientIp: authResult?.clientIp ?? clientIp,
|
|
222
|
+
authResult,
|
|
223
|
+
params: matchedRequest.params,
|
|
224
|
+
projectGroup: groupContainer,
|
|
225
|
+
waitUntil: (promise) => pendingWork2.push(promise)
|
|
226
|
+
};
|
|
227
|
+
await matchedRequest.controller(context);
|
|
228
|
+
if (abortSignal.aborted && ws.readyState === WebSocket.OPEN) {
|
|
229
|
+
ws.close(1012);
|
|
230
|
+
}
|
|
231
|
+
return { closed: closed2, pendingWork: pendingWork2, establishedAt: establishedAt2 };
|
|
232
|
+
} catch (error) {
|
|
233
|
+
const response = error instanceof HttpResponse ? error : new HttpErrorResponse(500, "Internal server error");
|
|
234
|
+
span.setAttribute("http.response.status_code", response.code);
|
|
235
|
+
if (response.code >= 500) {
|
|
236
|
+
span.setStatus("error");
|
|
237
|
+
}
|
|
238
|
+
if (!(error instanceof HttpResponse)) {
|
|
239
|
+
span.recordException(error);
|
|
240
|
+
requestLogger.error(error);
|
|
241
|
+
}
|
|
242
|
+
this.sendRawHttpResponse(socket, response);
|
|
243
|
+
requestLogger.debug("Websocket connection failed");
|
|
244
|
+
return void 0;
|
|
245
|
+
} finally {
|
|
246
|
+
span.end();
|
|
247
|
+
}
|
|
153
248
|
});
|
|
154
249
|
});
|
|
250
|
+
if (established === void 0) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const { closed, pendingWork, establishedAt } = established;
|
|
254
|
+
requestLogger.debug("Websocket connection established");
|
|
255
|
+
await closed;
|
|
256
|
+
await Promise.allSettled(pendingWork);
|
|
257
|
+
requestLogger.debug("Websocket connection closed", {
|
|
258
|
+
websocketOpenMs: performance.now() - establishedAt
|
|
259
|
+
});
|
|
155
260
|
} catch (e) {
|
|
156
261
|
if (e instanceof HttpResponse) {
|
|
157
262
|
this.sendRawHttpResponse(socket, e);
|
|
@@ -175,10 +280,51 @@ class Application {
|
|
|
175
280
|
if (internalMatchedRequest) {
|
|
176
281
|
return await this.handleInternalRequest(internalMatchedRequest, ctx);
|
|
177
282
|
}
|
|
283
|
+
return await this.processHttpRequest(ctx, null);
|
|
178
284
|
}
|
|
285
|
+
return await this.withIncomingTrace(ctx.req, async () => {
|
|
286
|
+
const span = this.tracer.startSpan(`HTTP ${ctx.request.method} ${matchedRequest.mask}`, {
|
|
287
|
+
kind: "server",
|
|
288
|
+
attributes: {
|
|
289
|
+
"http.request.method": ctx.request.method,
|
|
290
|
+
"url.path": ctx.request.URL.pathname,
|
|
291
|
+
"contember.module": matchedRequest.module
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
if (span.context.traceId === INVALID_TRACE_ID) {
|
|
295
|
+
return await this.processHttpRequest(ctx, matchedRequest, span);
|
|
296
|
+
}
|
|
297
|
+
const endSpan = () => {
|
|
298
|
+
ctx.res.off("finish", endSpan);
|
|
299
|
+
ctx.res.off("close", closeSpan);
|
|
300
|
+
span.end();
|
|
301
|
+
};
|
|
302
|
+
const closeSpan = () => {
|
|
303
|
+
if (!ctx.res.writableFinished) {
|
|
304
|
+
span.setStatus("error", "Response closed before completion");
|
|
305
|
+
}
|
|
306
|
+
endSpan();
|
|
307
|
+
};
|
|
308
|
+
ctx.res.once("finish", endSpan);
|
|
309
|
+
ctx.res.once("close", closeSpan);
|
|
310
|
+
try {
|
|
311
|
+
return await this.tracer.withSpan(span, () => this.processHttpRequest(ctx, matchedRequest, span));
|
|
312
|
+
} catch (error) {
|
|
313
|
+
span.recordException(error);
|
|
314
|
+
span.setStatus("error");
|
|
315
|
+
endSpan();
|
|
316
|
+
throw error;
|
|
317
|
+
} finally {
|
|
318
|
+
if (ctx.res.writableFinished) {
|
|
319
|
+
endSpan();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async processHttpRequest(ctx, matchedRequest, span) {
|
|
179
325
|
let httpContext = null;
|
|
180
326
|
const clientIp = getClientIP(ctx.req, this.trustedProxies);
|
|
181
|
-
let requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp);
|
|
327
|
+
let requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp, span?.context);
|
|
182
328
|
const { timer, send: sendTimer } = this.createTimer();
|
|
183
329
|
try {
|
|
184
330
|
if (!matchedRequest) {
|
|
@@ -195,11 +341,18 @@ class Application {
|
|
|
195
341
|
});
|
|
196
342
|
ctx.state.projectGroup = groupContainer.slug;
|
|
197
343
|
ctx.state.project = matchedRequest.params.projectSlug;
|
|
344
|
+
span?.setAttribute("contember.project_group", groupContainer.slug ?? "unknown");
|
|
345
|
+
if (matchedRequest.params.projectSlug !== void 0) {
|
|
346
|
+
span?.setAttribute("contember.project", matchedRequest.params.projectSlug);
|
|
347
|
+
}
|
|
198
348
|
const authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer, clientIp });
|
|
199
349
|
requestLogger.debug("User authenticated", { authResult });
|
|
200
350
|
requestLogger = requestLogger.child({
|
|
201
351
|
user: authResult?.identityId
|
|
202
352
|
});
|
|
353
|
+
if (authResult) {
|
|
354
|
+
span?.setAttribute("contember.identity_id", authResult.identityId);
|
|
355
|
+
}
|
|
203
356
|
const effectiveClientIp = authResult?.clientIp ?? clientIp;
|
|
204
357
|
const response = await requestLogger.scope(async (logger) => {
|
|
205
358
|
httpContext = {
|
|
@@ -209,6 +362,7 @@ class Application {
|
|
|
209
362
|
clientIp: effectiveClientIp,
|
|
210
363
|
logger,
|
|
211
364
|
timer,
|
|
365
|
+
tracer: this.tracer,
|
|
212
366
|
request: ctx.req,
|
|
213
367
|
response: ctx.res,
|
|
214
368
|
requestDebugMode: false,
|
|
@@ -226,20 +380,49 @@ class Application {
|
|
|
226
380
|
this.sendHttpResponse(ctx, e);
|
|
227
381
|
} else {
|
|
228
382
|
this.sendHttpResponse(ctx, new HttpErrorResponse(500, "Internal server error"));
|
|
383
|
+
span?.recordException(e);
|
|
384
|
+
span?.setStatus("error");
|
|
229
385
|
requestLogger.error(e);
|
|
230
386
|
}
|
|
231
387
|
} finally {
|
|
388
|
+
const responseStatus = ctx.status;
|
|
389
|
+
if (responseStatus >= 500) {
|
|
390
|
+
span?.setStatus("error");
|
|
391
|
+
}
|
|
232
392
|
this.maybeForceHttpOk(ctx, matchedRequest?.module);
|
|
393
|
+
const requestDebugMode = httpContext?.requestDebugMode ?? false;
|
|
394
|
+
span?.setAttribute("http.response.status_code", ctx.status);
|
|
395
|
+
this.sendTraceIdHeader(ctx, span, requestDebugMode);
|
|
396
|
+
if (span !== void 0 && span.context.traceId !== INVALID_TRACE_ID && ctx.response.body instanceof Readable) {
|
|
397
|
+
const contentLength = ctx.response.get("Content-Length");
|
|
398
|
+
ctx.body = createTracedReadable(ctx.response.body, this.tracer, span);
|
|
399
|
+
if (contentLength !== "") {
|
|
400
|
+
ctx.set("Content-Length", contentLength);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
233
403
|
sendTimer({
|
|
234
404
|
req: ctx.req,
|
|
235
405
|
response: ctx.res,
|
|
236
406
|
body: ctx.response.body,
|
|
237
|
-
requestDebugMode
|
|
407
|
+
requestDebugMode,
|
|
238
408
|
logger: requestLogger
|
|
239
409
|
});
|
|
240
410
|
requestLogger.debug("Request processing finished");
|
|
241
411
|
}
|
|
242
412
|
}
|
|
413
|
+
withIncomingTrace(request, cb) {
|
|
414
|
+
const incoming = resolveIncomingSpanContext(request, { mode: this.acceptIncomingTrace, trustedProxies: this.trustedProxies });
|
|
415
|
+
return incoming === void 0 ? cb() : withSpanContext(incoming, cb);
|
|
416
|
+
}
|
|
417
|
+
sendTraceIdHeader(ctx, span, requestDebugMode) {
|
|
418
|
+
if (span === void 0 || ctx.res.headersSent || span.context.traceId === INVALID_TRACE_ID) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (!this.traceIdResponseHeader && !this.debugMode && !requestDebugMode) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
ctx.set("x-contember-trace-id", span.context.traceId);
|
|
425
|
+
}
|
|
243
426
|
async handleInternalRequest(matchedRequest, ctx) {
|
|
244
427
|
try {
|
|
245
428
|
const response = await this.logger.scope(async (logger) => {
|
|
@@ -290,13 +473,33 @@ class Application {
|
|
|
290
473
|
if (response.contentType) {
|
|
291
474
|
ctx.set("Content-type", response.contentType);
|
|
292
475
|
}
|
|
476
|
+
for (const [name, value] of Object.entries(response.headers ?? {})) {
|
|
477
|
+
ctx.set(name, value);
|
|
478
|
+
}
|
|
293
479
|
ctx.status = response.code;
|
|
294
480
|
if (response.body !== void 0) {
|
|
295
481
|
ctx.body = response.body;
|
|
296
482
|
}
|
|
297
483
|
}
|
|
484
|
+
async closeWebsocket(ws) {
|
|
485
|
+
if (ws.readyState === WebSocket.CLOSED) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
ws.close(1012);
|
|
489
|
+
await new Promise((resolve) => {
|
|
490
|
+
const timeout = setTimeout(() => {
|
|
491
|
+
ws.terminate();
|
|
492
|
+
resolve();
|
|
493
|
+
}, websocketCloseTimeoutMs);
|
|
494
|
+
ws.once("close", () => {
|
|
495
|
+
clearTimeout(timeout);
|
|
496
|
+
resolve();
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
}
|
|
298
500
|
sendRawHttpResponse(socket, response) {
|
|
299
501
|
const headers = {
|
|
502
|
+
...response.headers,
|
|
300
503
|
"Connection": "close",
|
|
301
504
|
"Content-Type": response.contentType ?? "text/plain",
|
|
302
505
|
"Content-Length": String(response.body?.length ?? 0)
|
|
@@ -307,13 +510,15 @@ class Application {
|
|
|
307
510
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + (response.body ?? "")
|
|
308
511
|
);
|
|
309
512
|
}
|
|
310
|
-
createRequestLogger(request, body, module, remoteAddress) {
|
|
513
|
+
createRequestLogger(request, body, module, remoteAddress, spanContext) {
|
|
514
|
+
const traceAttributes = spanContext === void 0 || spanContext.traceId === INVALID_TRACE_ID ? {} : { traceId: spanContext.traceId, spanId: spanContext.spanId };
|
|
311
515
|
return this.logger.child({
|
|
312
516
|
method: request.method,
|
|
313
517
|
uri: request.url,
|
|
314
518
|
requestId: Math.random().toString().substring(2),
|
|
315
519
|
module,
|
|
316
520
|
remoteAddress,
|
|
521
|
+
...traceAttributes,
|
|
317
522
|
[LoggerRequestBody]: body
|
|
318
523
|
}, {
|
|
319
524
|
handler: FingerCrossedLoggerHandler.factory()
|
|
@@ -324,23 +529,7 @@ class Application {
|
|
|
324
529
|
const globalStart = performance.now();
|
|
325
530
|
const cpuUsageStart = cpuUsage();
|
|
326
531
|
const memoryUsageStart = memoryUsage();
|
|
327
|
-
const timer = (
|
|
328
|
-
const start = performance.now();
|
|
329
|
-
const time = { label: name, start: Math.round(start - globalStart) };
|
|
330
|
-
times.push(time);
|
|
331
|
-
const res = cb();
|
|
332
|
-
if (res instanceof Promise) {
|
|
333
|
-
(async () => {
|
|
334
|
-
try {
|
|
335
|
-
await res;
|
|
336
|
-
} catch {
|
|
337
|
-
} finally {
|
|
338
|
-
time.duration = Math.round(performance.now() - start);
|
|
339
|
-
}
|
|
340
|
-
})();
|
|
341
|
-
}
|
|
342
|
-
return res;
|
|
343
|
-
};
|
|
532
|
+
const timer = createEventTimer(this.tracer, times, globalStart);
|
|
344
533
|
const send = (ctx) => {
|
|
345
534
|
if (ctx.response && !ctx.response.headersSent && (ctx.requestDebugMode || this.debugMode) && times.length) {
|
|
346
535
|
ctx.response.setHeader("server-timing", times.map((it) => `${it.label};desc="${it.label} T+${it.start}";dur=${it.duration ?? -1}`).join(", "));
|
|
@@ -384,12 +573,49 @@ class Application {
|
|
|
384
573
|
for (const route of routes) {
|
|
385
574
|
const params = route.match({ url });
|
|
386
575
|
if (params !== null) {
|
|
387
|
-
return { params, controller: route.controller, module: route.module };
|
|
576
|
+
return { params, controller: route.controller, module: route.module, mask: route.mask };
|
|
388
577
|
}
|
|
389
578
|
}
|
|
390
579
|
return null;
|
|
391
580
|
}
|
|
392
581
|
}
|
|
582
|
+
const createEventTimer = (tracer, times, globalStart) => (name, cb) => {
|
|
583
|
+
const start = performance.now();
|
|
584
|
+
const time = { label: name, start: Math.round(start - globalStart) };
|
|
585
|
+
times.push(time);
|
|
586
|
+
const res = tracer.span(name, () => cb());
|
|
587
|
+
if (res instanceof Promise) {
|
|
588
|
+
(async () => {
|
|
589
|
+
try {
|
|
590
|
+
await res;
|
|
591
|
+
} catch {
|
|
592
|
+
} finally {
|
|
593
|
+
time.duration = Math.round(performance.now() - start);
|
|
594
|
+
}
|
|
595
|
+
})();
|
|
596
|
+
}
|
|
597
|
+
return res;
|
|
598
|
+
};
|
|
599
|
+
const createTracedReadable = (body, tracer, span) => {
|
|
600
|
+
const iterator = body[Symbol.asyncIterator]();
|
|
601
|
+
return Readable.from((async function* () {
|
|
602
|
+
let completed = false;
|
|
603
|
+
try {
|
|
604
|
+
while (true) {
|
|
605
|
+
const next = await tracer.withSpan(span, () => iterator.next());
|
|
606
|
+
if (next.done) {
|
|
607
|
+
completed = true;
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
yield next.value;
|
|
611
|
+
}
|
|
612
|
+
} finally {
|
|
613
|
+
if (!completed && iterator.return !== void 0) {
|
|
614
|
+
await tracer.withSpan(span, () => iterator.return?.());
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
})());
|
|
618
|
+
};
|
|
393
619
|
const createRequestMatcher = (mask) => {
|
|
394
620
|
const { regexp, keys } = pathToRegexp(mask);
|
|
395
621
|
const match = function(url) {
|
|
@@ -406,6 +632,7 @@ const createRequestMatcher = (mask) => {
|
|
|
406
632
|
const LoggerRequestBody = /* @__PURE__ */ Symbol("RequestBody");
|
|
407
633
|
export {
|
|
408
634
|
Application,
|
|
409
|
-
LoggerRequestBody
|
|
635
|
+
LoggerRequestBody,
|
|
636
|
+
createEventTimer
|
|
410
637
|
};
|
|
411
638
|
//# sourceMappingURL=application.js.map
|