@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
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const pathToRegexp = require("path-to-regexp");
|
|
4
4
|
const HttpResponse = require("../common/HttpResponse.cjs");
|
|
5
5
|
require("ipaddr.js");
|
|
6
|
+
require("@contember/engine-tenant-api");
|
|
6
7
|
const Koa = require("koa");
|
|
7
8
|
const http = require("node:http");
|
|
8
9
|
const ws = require("ws");
|
|
@@ -16,6 +17,8 @@ const node_process = require("node:process");
|
|
|
16
17
|
const node_perf_hooks = require("node:perf_hooks");
|
|
17
18
|
const remoteAddress = require("../utils/remoteAddress.cjs");
|
|
18
19
|
const forceHttpOk = require("./forceHttpOk.cjs");
|
|
20
|
+
const telemetry = require("@contember/telemetry");
|
|
21
|
+
const incomingTrace = require("../telemetry/incomingTrace.cjs");
|
|
19
22
|
function _interopNamespaceDefault(e) {
|
|
20
23
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
21
24
|
if (e) {
|
|
@@ -36,13 +39,15 @@ const http__namespace = /* @__PURE__ */ _interopNamespaceDefault(http);
|
|
|
36
39
|
var __defProp = Object.defineProperty;
|
|
37
40
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
38
41
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
42
|
+
const websocketCloseTimeoutMs = 5e3;
|
|
39
43
|
class Application {
|
|
40
|
-
constructor(projectGroupResolver, serverConfig, debugMode, version, logger2) {
|
|
44
|
+
constructor(projectGroupResolver, serverConfig, debugMode, version, logger2, tracer = telemetry.noopTracer) {
|
|
41
45
|
this.projectGroupResolver = projectGroupResolver;
|
|
42
46
|
this.serverConfig = serverConfig;
|
|
43
47
|
this.debugMode = debugMode;
|
|
44
48
|
this.version = version;
|
|
45
49
|
this.logger = logger2;
|
|
50
|
+
this.tracer = tracer;
|
|
46
51
|
__publicField(this, "middlewares", []);
|
|
47
52
|
__publicField(this, "routes", []);
|
|
48
53
|
__publicField(this, "internalRoutes", []);
|
|
@@ -50,10 +55,14 @@ class Application {
|
|
|
50
55
|
__publicField(this, "suppressAccessLog");
|
|
51
56
|
__publicField(this, "trustedProxies");
|
|
52
57
|
__publicField(this, "forceHttpOkEnabled");
|
|
58
|
+
__publicField(this, "acceptIncomingTrace");
|
|
59
|
+
__publicField(this, "traceIdResponseHeader");
|
|
53
60
|
const suppressAccessLogRaw = serverConfig.http?.suppressAccessLog;
|
|
54
61
|
this.suppressAccessLog = suppressAccessLogRaw === true ? true : suppressAccessLogRaw ? new RegExp(suppressAccessLogRaw) : false;
|
|
55
62
|
this.trustedProxies = serverConfig.http?.trustedProxies ?? [];
|
|
56
63
|
this.forceHttpOkEnabled = serverConfig.http?.responseStatusHeader ?? true;
|
|
64
|
+
this.acceptIncomingTrace = serverConfig.telemetry?.traces?.acceptIncoming ?? "trusted-proxies";
|
|
65
|
+
this.traceIdResponseHeader = serverConfig.telemetry?.traces?.traceIdResponseHeader ?? false;
|
|
57
66
|
}
|
|
58
67
|
addMiddleware(middleware) {
|
|
59
68
|
this.middlewares.push(middleware);
|
|
@@ -62,6 +71,7 @@ class Application {
|
|
|
62
71
|
this.routes.push({
|
|
63
72
|
module: module2,
|
|
64
73
|
controller,
|
|
74
|
+
mask,
|
|
65
75
|
match: createRequestMatcher(mask)
|
|
66
76
|
});
|
|
67
77
|
}
|
|
@@ -69,6 +79,7 @@ class Application {
|
|
|
69
79
|
this.internalRoutes.push({
|
|
70
80
|
module: module2,
|
|
71
81
|
controller,
|
|
82
|
+
mask,
|
|
72
83
|
match: createRequestMatcher(mask)
|
|
73
84
|
});
|
|
74
85
|
}
|
|
@@ -76,12 +87,22 @@ class Application {
|
|
|
76
87
|
this.websocketRoutes.push({
|
|
77
88
|
module: module2,
|
|
78
89
|
controller,
|
|
90
|
+
mask,
|
|
79
91
|
match: createRequestMatcher(mask)
|
|
80
92
|
});
|
|
81
93
|
}
|
|
82
94
|
async listen() {
|
|
83
95
|
const koa = new Koa();
|
|
84
96
|
const wss = new ws.WebSocketServer({ noServer: true });
|
|
97
|
+
let closing = false;
|
|
98
|
+
koa.use(async (ctx, next) => {
|
|
99
|
+
if (closing) {
|
|
100
|
+
ctx.status = 503;
|
|
101
|
+
ctx.set("Connection", "close");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
await next();
|
|
105
|
+
});
|
|
85
106
|
for (const middleware of this.middlewares) {
|
|
86
107
|
koa.use(middleware);
|
|
87
108
|
}
|
|
@@ -91,18 +112,44 @@ class Application {
|
|
|
91
112
|
koa.use(bodyParser({
|
|
92
113
|
jsonLimit: this.serverConfig.http?.requestBodySize || "1mb"
|
|
93
114
|
}));
|
|
94
|
-
koa.use(corsMiddleware());
|
|
115
|
+
koa.use(corsMiddleware({ exposeHeaders: ["X-Contember-Mutation"] }));
|
|
95
116
|
const versionMatch = this.version?.match(/^(0\.\d+|\d+)/);
|
|
96
117
|
const versionSimplified = versionMatch?.[1] ?? "unknown";
|
|
97
118
|
koa.use(async (ctx) => {
|
|
98
119
|
ctx.response.set("X-Powered-By", `Contember ${versionSimplified}` + (this.debugMode ? "-dev" : ""));
|
|
99
120
|
await this.handleHttpRequest(ctx);
|
|
100
121
|
});
|
|
101
|
-
const
|
|
122
|
+
const activeHttpRequests = /* @__PURE__ */ new Set();
|
|
123
|
+
const handleHttpRequest = koa.callback();
|
|
124
|
+
const server = http__namespace.createServer((request, response) => {
|
|
125
|
+
if (closing) {
|
|
126
|
+
handleHttpRequest(request, response);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let resolveRequest = () => {
|
|
130
|
+
};
|
|
131
|
+
const completed = new Promise((resolve) => {
|
|
132
|
+
resolveRequest = resolve;
|
|
133
|
+
});
|
|
134
|
+
activeHttpRequests.add(completed);
|
|
135
|
+
const complete = () => {
|
|
136
|
+
response.off("finish", complete);
|
|
137
|
+
response.off("close", complete);
|
|
138
|
+
activeHttpRequests.delete(completed);
|
|
139
|
+
resolveRequest();
|
|
140
|
+
};
|
|
141
|
+
response.once("finish", complete);
|
|
142
|
+
response.once("close", complete);
|
|
143
|
+
handleHttpRequest(request, response);
|
|
144
|
+
});
|
|
102
145
|
const abortController = new AbortController();
|
|
103
146
|
const wsRequests = [];
|
|
104
147
|
server.on("upgrade", (req, socket, head) => {
|
|
105
|
-
|
|
148
|
+
if (closing) {
|
|
149
|
+
this.sendRawHttpResponse(socket, new HttpResponse.HttpErrorResponse(503, "Server is shutting down"));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
wsRequests.push(this.handleWebsocketRequest(wss, abortController.signal, req, socket, head).finally(() => socket.destroy()));
|
|
106
153
|
});
|
|
107
154
|
await new Promise((resolve) => {
|
|
108
155
|
server.listen(this.serverConfig.port, () => resolve());
|
|
@@ -110,14 +157,28 @@ class Application {
|
|
|
110
157
|
return {
|
|
111
158
|
server,
|
|
112
159
|
close: async () => {
|
|
160
|
+
closing = true;
|
|
113
161
|
abortController.abort();
|
|
114
|
-
await Promise.all(wsRequests);
|
|
115
|
-
|
|
162
|
+
await Promise.all([...wsRequests, ...activeHttpRequests]);
|
|
163
|
+
if (process.versions.bun !== void 0) {
|
|
164
|
+
server.closeAllConnections();
|
|
165
|
+
} else {
|
|
166
|
+
server.closeIdleConnections();
|
|
167
|
+
}
|
|
168
|
+
if (server.listening) {
|
|
169
|
+
await new Promise(
|
|
170
|
+
(resolve) => server.close((error) => {
|
|
171
|
+
if (error) {
|
|
172
|
+
this.logger.error(error);
|
|
173
|
+
}
|
|
174
|
+
resolve();
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
}
|
|
116
178
|
}
|
|
117
179
|
};
|
|
118
180
|
}
|
|
119
181
|
async handleWebsocketRequest(wss, abortSignal, req, socket, head) {
|
|
120
|
-
let webSocketContext = null;
|
|
121
182
|
let requestLogger = this.logger;
|
|
122
183
|
const { timer, send: sendTimer } = this.createTimer();
|
|
123
184
|
const clientIp = remoteAddress.getClientIP(req, this.trustedProxies);
|
|
@@ -127,50 +188,94 @@ class Application {
|
|
|
127
188
|
if (!matchedRequest) {
|
|
128
189
|
throw new HttpResponse.HttpErrorResponse(404, "Route not found");
|
|
129
190
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
user: authResult?.identityId
|
|
139
|
-
});
|
|
140
|
-
const effectiveClientIp = authResult?.clientIp ?? clientIp;
|
|
141
|
-
const ws2 = await new Promise(
|
|
142
|
-
(resolve) => wss.handleUpgrade(req, socket, head, (ws22, request) => {
|
|
143
|
-
resolve(ws22);
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
const wsEstablished = node_perf_hooks.performance.now();
|
|
147
|
-
webSocketContext = {
|
|
148
|
-
ws: ws2,
|
|
149
|
-
abortSignal,
|
|
150
|
-
logger: requestLogger,
|
|
151
|
-
timer,
|
|
152
|
-
url,
|
|
153
|
-
request: req,
|
|
154
|
-
clientIp: effectiveClientIp,
|
|
155
|
-
authResult,
|
|
156
|
-
params: matchedRequest.params,
|
|
157
|
-
projectGroup: groupContainer
|
|
158
|
-
};
|
|
159
|
-
await matchedRequest.controller(webSocketContext);
|
|
160
|
-
requestLogger.debug("Websocket connection established");
|
|
161
|
-
ws2.on("error", (e) => {
|
|
162
|
-
requestLogger.error(e, {
|
|
163
|
-
websocketOpenMs: node_perf_hooks.performance.now() - wsEstablished
|
|
191
|
+
const established = await this.withIncomingTrace(req, async () => {
|
|
192
|
+
const span = this.tracer.startSpan(`WS ${matchedRequest.mask}`, {
|
|
193
|
+
kind: "server",
|
|
194
|
+
attributes: {
|
|
195
|
+
"http.request.method": req.method ?? "GET",
|
|
196
|
+
"url.path": url.pathname,
|
|
197
|
+
"contember.module": matchedRequest.module
|
|
198
|
+
}
|
|
164
199
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
200
|
+
return await this.tracer.withSpan(span, async () => {
|
|
201
|
+
const pendingWork2 = [];
|
|
202
|
+
try {
|
|
203
|
+
requestLogger = this.createRequestLogger(req, void 0, matchedRequest.module, clientIp, span.context);
|
|
204
|
+
const groupContainer = await this.projectGroupResolver.resolveContainer({ request: req });
|
|
205
|
+
requestLogger = requestLogger.child({ projectGroup: groupContainer.slug });
|
|
206
|
+
span.setAttribute("contember.project_group", groupContainer.slug ?? "unknown");
|
|
207
|
+
if (matchedRequest.params.projectSlug !== void 0) {
|
|
208
|
+
span.setAttribute("contember.project", matchedRequest.params.projectSlug);
|
|
209
|
+
}
|
|
210
|
+
const authResult = await groupContainer.authenticator.authenticate({ request: req, timer, clientIp });
|
|
211
|
+
requestLogger.debug("User authenticated", { authResult });
|
|
212
|
+
requestLogger = requestLogger.child({ user: authResult?.identityId });
|
|
213
|
+
if (authResult) {
|
|
214
|
+
span.setAttribute("contember.identity_id", authResult.identityId);
|
|
215
|
+
}
|
|
216
|
+
if (abortSignal.aborted) {
|
|
217
|
+
throw new HttpResponse.HttpErrorResponse(503, "Server is shutting down");
|
|
218
|
+
}
|
|
219
|
+
const ws$1 = await new Promise((resolve) => wss.handleUpgrade(req, socket, head, (ws2) => resolve(ws2)));
|
|
220
|
+
const establishedAt2 = node_perf_hooks.performance.now();
|
|
221
|
+
const closed2 = new Promise((resolve) => ws$1.once("close", () => resolve()));
|
|
222
|
+
ws$1.on("error", (e) => {
|
|
223
|
+
requestLogger.error(e, {
|
|
224
|
+
websocketOpenMs: node_perf_hooks.performance.now() - establishedAt2
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
span.setAttribute("http.response.status_code", 101);
|
|
228
|
+
if (abortSignal.aborted) {
|
|
229
|
+
await this.closeWebsocket(ws$1);
|
|
230
|
+
return void 0;
|
|
231
|
+
}
|
|
232
|
+
const context = {
|
|
233
|
+
ws: ws$1,
|
|
234
|
+
abortSignal,
|
|
235
|
+
logger: requestLogger,
|
|
236
|
+
timer,
|
|
237
|
+
tracer: this.tracer,
|
|
238
|
+
url,
|
|
239
|
+
request: req,
|
|
240
|
+
clientIp: authResult?.clientIp ?? clientIp,
|
|
241
|
+
authResult,
|
|
242
|
+
params: matchedRequest.params,
|
|
243
|
+
projectGroup: groupContainer,
|
|
244
|
+
waitUntil: (promise) => pendingWork2.push(promise)
|
|
245
|
+
};
|
|
246
|
+
await matchedRequest.controller(context);
|
|
247
|
+
if (abortSignal.aborted && ws$1.readyState === ws.WebSocket.OPEN) {
|
|
248
|
+
ws$1.close(1012);
|
|
249
|
+
}
|
|
250
|
+
return { closed: closed2, pendingWork: pendingWork2, establishedAt: establishedAt2 };
|
|
251
|
+
} catch (error) {
|
|
252
|
+
const response = error instanceof HttpResponse.HttpResponse ? error : new HttpResponse.HttpErrorResponse(500, "Internal server error");
|
|
253
|
+
span.setAttribute("http.response.status_code", response.code);
|
|
254
|
+
if (response.code >= 500) {
|
|
255
|
+
span.setStatus("error");
|
|
256
|
+
}
|
|
257
|
+
if (!(error instanceof HttpResponse.HttpResponse)) {
|
|
258
|
+
span.recordException(error);
|
|
259
|
+
requestLogger.error(error);
|
|
260
|
+
}
|
|
261
|
+
this.sendRawHttpResponse(socket, response);
|
|
262
|
+
requestLogger.debug("Websocket connection failed");
|
|
263
|
+
return void 0;
|
|
264
|
+
} finally {
|
|
265
|
+
span.end();
|
|
266
|
+
}
|
|
172
267
|
});
|
|
173
268
|
});
|
|
269
|
+
if (established === void 0) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const { closed, pendingWork, establishedAt } = established;
|
|
273
|
+
requestLogger.debug("Websocket connection established");
|
|
274
|
+
await closed;
|
|
275
|
+
await Promise.allSettled(pendingWork);
|
|
276
|
+
requestLogger.debug("Websocket connection closed", {
|
|
277
|
+
websocketOpenMs: node_perf_hooks.performance.now() - establishedAt
|
|
278
|
+
});
|
|
174
279
|
} catch (e) {
|
|
175
280
|
if (e instanceof HttpResponse.HttpResponse) {
|
|
176
281
|
this.sendRawHttpResponse(socket, e);
|
|
@@ -194,10 +299,51 @@ class Application {
|
|
|
194
299
|
if (internalMatchedRequest) {
|
|
195
300
|
return await this.handleInternalRequest(internalMatchedRequest, ctx);
|
|
196
301
|
}
|
|
302
|
+
return await this.processHttpRequest(ctx, null);
|
|
197
303
|
}
|
|
304
|
+
return await this.withIncomingTrace(ctx.req, async () => {
|
|
305
|
+
const span = this.tracer.startSpan(`HTTP ${ctx.request.method} ${matchedRequest.mask}`, {
|
|
306
|
+
kind: "server",
|
|
307
|
+
attributes: {
|
|
308
|
+
"http.request.method": ctx.request.method,
|
|
309
|
+
"url.path": ctx.request.URL.pathname,
|
|
310
|
+
"contember.module": matchedRequest.module
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
if (span.context.traceId === telemetry.INVALID_TRACE_ID) {
|
|
314
|
+
return await this.processHttpRequest(ctx, matchedRequest, span);
|
|
315
|
+
}
|
|
316
|
+
const endSpan = () => {
|
|
317
|
+
ctx.res.off("finish", endSpan);
|
|
318
|
+
ctx.res.off("close", closeSpan);
|
|
319
|
+
span.end();
|
|
320
|
+
};
|
|
321
|
+
const closeSpan = () => {
|
|
322
|
+
if (!ctx.res.writableFinished) {
|
|
323
|
+
span.setStatus("error", "Response closed before completion");
|
|
324
|
+
}
|
|
325
|
+
endSpan();
|
|
326
|
+
};
|
|
327
|
+
ctx.res.once("finish", endSpan);
|
|
328
|
+
ctx.res.once("close", closeSpan);
|
|
329
|
+
try {
|
|
330
|
+
return await this.tracer.withSpan(span, () => this.processHttpRequest(ctx, matchedRequest, span));
|
|
331
|
+
} catch (error) {
|
|
332
|
+
span.recordException(error);
|
|
333
|
+
span.setStatus("error");
|
|
334
|
+
endSpan();
|
|
335
|
+
throw error;
|
|
336
|
+
} finally {
|
|
337
|
+
if (ctx.res.writableFinished) {
|
|
338
|
+
endSpan();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
async processHttpRequest(ctx, matchedRequest, span) {
|
|
198
344
|
let httpContext = null;
|
|
199
345
|
const clientIp = remoteAddress.getClientIP(ctx.req, this.trustedProxies);
|
|
200
|
-
let requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp);
|
|
346
|
+
let requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp, span?.context);
|
|
201
347
|
const { timer, send: sendTimer } = this.createTimer();
|
|
202
348
|
try {
|
|
203
349
|
if (!matchedRequest) {
|
|
@@ -214,11 +360,18 @@ class Application {
|
|
|
214
360
|
});
|
|
215
361
|
ctx.state.projectGroup = groupContainer.slug;
|
|
216
362
|
ctx.state.project = matchedRequest.params.projectSlug;
|
|
363
|
+
span?.setAttribute("contember.project_group", groupContainer.slug ?? "unknown");
|
|
364
|
+
if (matchedRequest.params.projectSlug !== void 0) {
|
|
365
|
+
span?.setAttribute("contember.project", matchedRequest.params.projectSlug);
|
|
366
|
+
}
|
|
217
367
|
const authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer, clientIp });
|
|
218
368
|
requestLogger.debug("User authenticated", { authResult });
|
|
219
369
|
requestLogger = requestLogger.child({
|
|
220
370
|
user: authResult?.identityId
|
|
221
371
|
});
|
|
372
|
+
if (authResult) {
|
|
373
|
+
span?.setAttribute("contember.identity_id", authResult.identityId);
|
|
374
|
+
}
|
|
222
375
|
const effectiveClientIp = authResult?.clientIp ?? clientIp;
|
|
223
376
|
const response = await requestLogger.scope(async (logger2) => {
|
|
224
377
|
httpContext = {
|
|
@@ -228,6 +381,7 @@ class Application {
|
|
|
228
381
|
clientIp: effectiveClientIp,
|
|
229
382
|
logger: logger2,
|
|
230
383
|
timer,
|
|
384
|
+
tracer: this.tracer,
|
|
231
385
|
request: ctx.req,
|
|
232
386
|
response: ctx.res,
|
|
233
387
|
requestDebugMode: false,
|
|
@@ -245,20 +399,49 @@ class Application {
|
|
|
245
399
|
this.sendHttpResponse(ctx, e);
|
|
246
400
|
} else {
|
|
247
401
|
this.sendHttpResponse(ctx, new HttpResponse.HttpErrorResponse(500, "Internal server error"));
|
|
402
|
+
span?.recordException(e);
|
|
403
|
+
span?.setStatus("error");
|
|
248
404
|
requestLogger.error(e);
|
|
249
405
|
}
|
|
250
406
|
} finally {
|
|
407
|
+
const responseStatus = ctx.status;
|
|
408
|
+
if (responseStatus >= 500) {
|
|
409
|
+
span?.setStatus("error");
|
|
410
|
+
}
|
|
251
411
|
this.maybeForceHttpOk(ctx, matchedRequest?.module);
|
|
412
|
+
const requestDebugMode = httpContext?.requestDebugMode ?? false;
|
|
413
|
+
span?.setAttribute("http.response.status_code", ctx.status);
|
|
414
|
+
this.sendTraceIdHeader(ctx, span, requestDebugMode);
|
|
415
|
+
if (span !== void 0 && span.context.traceId !== telemetry.INVALID_TRACE_ID && ctx.response.body instanceof node_stream.Readable) {
|
|
416
|
+
const contentLength = ctx.response.get("Content-Length");
|
|
417
|
+
ctx.body = createTracedReadable(ctx.response.body, this.tracer, span);
|
|
418
|
+
if (contentLength !== "") {
|
|
419
|
+
ctx.set("Content-Length", contentLength);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
252
422
|
sendTimer({
|
|
253
423
|
req: ctx.req,
|
|
254
424
|
response: ctx.res,
|
|
255
425
|
body: ctx.response.body,
|
|
256
|
-
requestDebugMode
|
|
426
|
+
requestDebugMode,
|
|
257
427
|
logger: requestLogger
|
|
258
428
|
});
|
|
259
429
|
requestLogger.debug("Request processing finished");
|
|
260
430
|
}
|
|
261
431
|
}
|
|
432
|
+
withIncomingTrace(request, cb) {
|
|
433
|
+
const incoming = incomingTrace.resolveIncomingSpanContext(request, { mode: this.acceptIncomingTrace, trustedProxies: this.trustedProxies });
|
|
434
|
+
return incoming === void 0 ? cb() : telemetry.withSpanContext(incoming, cb);
|
|
435
|
+
}
|
|
436
|
+
sendTraceIdHeader(ctx, span, requestDebugMode) {
|
|
437
|
+
if (span === void 0 || ctx.res.headersSent || span.context.traceId === telemetry.INVALID_TRACE_ID) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (!this.traceIdResponseHeader && !this.debugMode && !requestDebugMode) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
ctx.set("x-contember-trace-id", span.context.traceId);
|
|
444
|
+
}
|
|
262
445
|
async handleInternalRequest(matchedRequest, ctx) {
|
|
263
446
|
try {
|
|
264
447
|
const response = await this.logger.scope(async (logger2) => {
|
|
@@ -309,13 +492,33 @@ class Application {
|
|
|
309
492
|
if (response.contentType) {
|
|
310
493
|
ctx.set("Content-type", response.contentType);
|
|
311
494
|
}
|
|
495
|
+
for (const [name, value] of Object.entries(response.headers ?? {})) {
|
|
496
|
+
ctx.set(name, value);
|
|
497
|
+
}
|
|
312
498
|
ctx.status = response.code;
|
|
313
499
|
if (response.body !== void 0) {
|
|
314
500
|
ctx.body = response.body;
|
|
315
501
|
}
|
|
316
502
|
}
|
|
503
|
+
async closeWebsocket(ws$1) {
|
|
504
|
+
if (ws$1.readyState === ws.WebSocket.CLOSED) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
ws$1.close(1012);
|
|
508
|
+
await new Promise((resolve) => {
|
|
509
|
+
const timeout = setTimeout(() => {
|
|
510
|
+
ws$1.terminate();
|
|
511
|
+
resolve();
|
|
512
|
+
}, websocketCloseTimeoutMs);
|
|
513
|
+
ws$1.once("close", () => {
|
|
514
|
+
clearTimeout(timeout);
|
|
515
|
+
resolve();
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
}
|
|
317
519
|
sendRawHttpResponse(socket, response) {
|
|
318
520
|
const headers = {
|
|
521
|
+
...response.headers,
|
|
319
522
|
"Connection": "close",
|
|
320
523
|
"Content-Type": response.contentType ?? "text/plain",
|
|
321
524
|
"Content-Length": String(response.body?.length ?? 0)
|
|
@@ -326,13 +529,15 @@ class Application {
|
|
|
326
529
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + (response.body ?? "")
|
|
327
530
|
);
|
|
328
531
|
}
|
|
329
|
-
createRequestLogger(request, body, module2, remoteAddress2) {
|
|
532
|
+
createRequestLogger(request, body, module2, remoteAddress2, spanContext) {
|
|
533
|
+
const traceAttributes = spanContext === void 0 || spanContext.traceId === telemetry.INVALID_TRACE_ID ? {} : { traceId: spanContext.traceId, spanId: spanContext.spanId };
|
|
330
534
|
return this.logger.child({
|
|
331
535
|
method: request.method,
|
|
332
536
|
uri: request.url,
|
|
333
537
|
requestId: Math.random().toString().substring(2),
|
|
334
538
|
module: module2,
|
|
335
539
|
remoteAddress: remoteAddress2,
|
|
540
|
+
...traceAttributes,
|
|
336
541
|
[LoggerRequestBody]: body
|
|
337
542
|
}, {
|
|
338
543
|
handler: logger.FingerCrossedLoggerHandler.factory()
|
|
@@ -343,23 +548,7 @@ class Application {
|
|
|
343
548
|
const globalStart = node_perf_hooks.performance.now();
|
|
344
549
|
const cpuUsageStart = node_process.cpuUsage();
|
|
345
550
|
const memoryUsageStart = node_process.memoryUsage();
|
|
346
|
-
const timer = (
|
|
347
|
-
const start = node_perf_hooks.performance.now();
|
|
348
|
-
const time = { label: name, start: Math.round(start - globalStart) };
|
|
349
|
-
times.push(time);
|
|
350
|
-
const res = cb();
|
|
351
|
-
if (res instanceof Promise) {
|
|
352
|
-
(async () => {
|
|
353
|
-
try {
|
|
354
|
-
await res;
|
|
355
|
-
} catch {
|
|
356
|
-
} finally {
|
|
357
|
-
time.duration = Math.round(node_perf_hooks.performance.now() - start);
|
|
358
|
-
}
|
|
359
|
-
})();
|
|
360
|
-
}
|
|
361
|
-
return res;
|
|
362
|
-
};
|
|
551
|
+
const timer = createEventTimer(this.tracer, times, globalStart);
|
|
363
552
|
const send = (ctx) => {
|
|
364
553
|
if (ctx.response && !ctx.response.headersSent && (ctx.requestDebugMode || this.debugMode) && times.length) {
|
|
365
554
|
ctx.response.setHeader("server-timing", times.map((it) => `${it.label};desc="${it.label} T+${it.start}";dur=${it.duration ?? -1}`).join(", "));
|
|
@@ -403,12 +592,49 @@ class Application {
|
|
|
403
592
|
for (const route of routes) {
|
|
404
593
|
const params = route.match({ url });
|
|
405
594
|
if (params !== null) {
|
|
406
|
-
return { params, controller: route.controller, module: route.module };
|
|
595
|
+
return { params, controller: route.controller, module: route.module, mask: route.mask };
|
|
407
596
|
}
|
|
408
597
|
}
|
|
409
598
|
return null;
|
|
410
599
|
}
|
|
411
600
|
}
|
|
601
|
+
const createEventTimer = (tracer, times, globalStart) => (name, cb) => {
|
|
602
|
+
const start = node_perf_hooks.performance.now();
|
|
603
|
+
const time = { label: name, start: Math.round(start - globalStart) };
|
|
604
|
+
times.push(time);
|
|
605
|
+
const res = tracer.span(name, () => cb());
|
|
606
|
+
if (res instanceof Promise) {
|
|
607
|
+
(async () => {
|
|
608
|
+
try {
|
|
609
|
+
await res;
|
|
610
|
+
} catch {
|
|
611
|
+
} finally {
|
|
612
|
+
time.duration = Math.round(node_perf_hooks.performance.now() - start);
|
|
613
|
+
}
|
|
614
|
+
})();
|
|
615
|
+
}
|
|
616
|
+
return res;
|
|
617
|
+
};
|
|
618
|
+
const createTracedReadable = (body, tracer, span) => {
|
|
619
|
+
const iterator = body[Symbol.asyncIterator]();
|
|
620
|
+
return node_stream.Readable.from((async function* () {
|
|
621
|
+
let completed = false;
|
|
622
|
+
try {
|
|
623
|
+
while (true) {
|
|
624
|
+
const next = await tracer.withSpan(span, () => iterator.next());
|
|
625
|
+
if (next.done) {
|
|
626
|
+
completed = true;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
yield next.value;
|
|
630
|
+
}
|
|
631
|
+
} finally {
|
|
632
|
+
if (!completed && iterator.return !== void 0) {
|
|
633
|
+
await tracer.withSpan(span, () => iterator.return?.());
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
})());
|
|
637
|
+
};
|
|
412
638
|
const createRequestMatcher = (mask) => {
|
|
413
639
|
const { regexp, keys } = pathToRegexp.pathToRegexp(mask);
|
|
414
640
|
const match = function(url) {
|
|
@@ -425,4 +651,5 @@ const createRequestMatcher = (mask) => {
|
|
|
425
651
|
const LoggerRequestBody = /* @__PURE__ */ Symbol("RequestBody");
|
|
426
652
|
exports.Application = Application;
|
|
427
653
|
exports.LoggerRequestBody = LoggerRequestBody;
|
|
654
|
+
exports.createEventTimer = createEventTimer;
|
|
428
655
|
//# sourceMappingURL=application.cjs.map
|