@herrromich/az-functions 1.0.0
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/LICENSE +21 -0
- package/README.md +830 -0
- package/coverage/cobertura-coverage.xml +3482 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/context/forked-invocation-context.ts.html +127 -0
- package/coverage/lcov-report/context/index.html +191 -0
- package/coverage/lcov-report/context/index.ts.html +97 -0
- package/coverage/lcov-report/context/platform-context.manager.ts.html +193 -0
- package/coverage/lcov-report/context/platform-context.model.ts.html +262 -0
- package/coverage/lcov-report/context/platform-context.provider.ts.html +196 -0
- package/coverage/lcov-report/context/platform.execution.context.ts.html +217 -0
- package/coverage/lcov-report/context/wrapped-invocation-context.ts.html +163 -0
- package/coverage/lcov-report/event-hub-handler/azure-event-hub-trigger.model.ts.html +187 -0
- package/coverage/lcov-report/event-hub-handler/azure-event-hub-trigger.service.ts.html +760 -0
- package/coverage/lcov-report/event-hub-handler/decorators/decorators.model.ts.html +292 -0
- package/coverage/lcov-report/event-hub-handler/decorators/decorators.ts.html +778 -0
- package/coverage/lcov-report/event-hub-handler/decorators/index.html +146 -0
- package/coverage/lcov-report/event-hub-handler/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handle-method-args-metadata.service.ts.html +130 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler-metadata.reader.ts.html +199 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler-registration.service.ts.html +220 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler.factory.ts.html +283 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler.model.ts.html +421 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler.provider.ts.html +187 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger-support.factory.ts.html +787 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger-support.service.ts.html +829 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger.model.ts.html +193 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger.service.ts.html +859 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-triggers-registration.service.ts.html +307 -0
- package/coverage/lcov-report/event-hub-handler/index.html +221 -0
- package/coverage/lcov-report/event-hub-handler/index.ts.html +142 -0
- package/coverage/lcov-report/eventhub-handler/decorators/decorators.model.ts.html +277 -0
- package/coverage/lcov-report/eventhub-handler/decorators/decorators.ts.html +679 -0
- package/coverage/lcov-report/eventhub-handler/decorators/index.html +131 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler-metadata.reader.ts.html +196 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler-registration.service.ts.html +220 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler.factory.ts.html +193 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler.model.ts.html +406 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-trigger.model.ts.html +187 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-trigger.service.ts.html +760 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-triggers-registration.service.ts.html +304 -0
- package/coverage/lcov-report/eventhub-handler/index.html +206 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/forked-invocation-context.ts.html +127 -0
- package/coverage/lcov-report/function-handler-metadata.reader.ts.html +172 -0
- package/coverage/lcov-report/http-controller/authentication.provider.ts.html +481 -0
- package/coverage/lcov-report/http-controller/authenticator.provider.ts.html +460 -0
- package/coverage/lcov-report/http-controller/azure-http-trigger.service.ts.html +1045 -0
- package/coverage/lcov-report/http-controller/decorators/decorators.model.ts.html +388 -0
- package/coverage/lcov-report/http-controller/decorators/decorators.ts.html +1627 -0
- package/coverage/lcov-report/http-controller/decorators/index.html +146 -0
- package/coverage/lcov-report/http-controller/decorators/index.ts.html +94 -0
- package/coverage/lcov-report/http-controller/http-controller-metadata.reader.ts.html +271 -0
- package/coverage/lcov-report/http-controller/http-controller-metadata.service.ts.html +130 -0
- package/coverage/lcov-report/http-controller/http-controller-platform.model.ts.html +187 -0
- package/coverage/lcov-report/http-controller/http-controller-registration.service.ts.html +241 -0
- package/coverage/lcov-report/http-controller/http-controller.model.ts.html +745 -0
- package/coverage/lcov-report/http-controller/http-handler-support.factory.ts.html +499 -0
- package/coverage/lcov-report/http-controller/http-handler.factory.ts.html +415 -0
- package/coverage/lcov-report/http-controller/http-operation-registration.service.ts.html +328 -0
- package/coverage/lcov-report/http-controller/http-operations-registration.service.ts.html +328 -0
- package/coverage/lcov-report/http-controller/http-request-arg-provider.factory.ts.html +580 -0
- package/coverage/lcov-report/http-controller/http-request-handler.provider.ts.html +388 -0
- package/coverage/lcov-report/http-controller/http-response-processor.factory.ts.html +316 -0
- package/coverage/lcov-report/http-controller/index.html +311 -0
- package/coverage/lcov-report/http-controller/index.ts.html +226 -0
- package/coverage/lcov-report/http-controller/open-api-definition.service.ts.html +568 -0
- package/coverage/lcov-report/http-controller/open-api-metadata.service.ts.html +373 -0
- package/coverage/lcov-report/http-controller/open-api-print.service.ts.html +232 -0
- package/coverage/lcov-report/http-controller/open-api-registration.service.ts.html +220 -0
- package/coverage/lcov-report/http-controller/rest-open-api.regstry.ts.html +262 -0
- package/coverage/lcov-report/http-controller/security/authentication-service.factory.ts.html +280 -0
- package/coverage/lcov-report/http-controller/security/authentication-service.ts.html +115 -0
- package/coverage/lcov-report/http-controller/security/authenticator.provider.ts.html +799 -0
- package/coverage/lcov-report/http-controller/security/bearer-security-authentication.service.ts.html +133 -0
- package/coverage/lcov-report/http-controller/security/index.html +206 -0
- package/coverage/lcov-report/http-controller/security/index.ts.html +94 -0
- package/coverage/lcov-report/http-controller/security/model.ts.html +133 -0
- package/coverage/lcov-report/http-controller/security/operation-authentication.resolver.ts.html +418 -0
- package/coverage/lcov-report/http-controller/security/principal-merge.service.ts.html +163 -0
- package/coverage/lcov-report/http-controller/security/strict-principal-merge.servce.ts.html +154 -0
- package/coverage/lcov-report/http-controller/swagger-handling.service.ts.html +463 -0
- package/coverage/lcov-report/index.html +281 -0
- package/coverage/lcov-report/init.ts.html +97 -0
- package/coverage/lcov-report/ioc-container.utils.ts.html +100 -0
- package/coverage/lcov-report/logger/azure-log-transport.service.ts.html +433 -0
- package/coverage/lcov-report/logger/bindings.ts.html +253 -0
- package/coverage/lcov-report/logger/index.html +221 -0
- package/coverage/lcov-report/logger/index.ts.html +163 -0
- package/coverage/lcov-report/logger/log-level.service.ts.html +127 -0
- package/coverage/lcov-report/logger/log-transport.service.ts.html +571 -0
- package/coverage/lcov-report/logger/logger-factory.provider.ts.html +142 -0
- package/coverage/lcov-report/logger/logger.factory.ts.html +172 -0
- package/coverage/lcov-report/logger/logger.model.ts.html +868 -0
- package/coverage/lcov-report/logger/logger.utils.ts.html +877 -0
- package/coverage/lcov-report/logger/model.ts.html +172 -0
- package/coverage/lcov-report/logger/otel.logger.ts.html +358 -0
- package/coverage/lcov-report/logger/platform.logger.ts.html +229 -0
- package/coverage/lcov-report/logger/trie-search.service.ts.html +616 -0
- package/coverage/lcov-report/platform/azure-platform.ts.html +256 -0
- package/coverage/lcov-report/platform/index.html +176 -0
- package/coverage/lcov-report/platform/index.ts.html +139 -0
- package/coverage/lcov-report/platform/platform-component-metadata.service.ts.html +115 -0
- package/coverage/lcov-report/platform/register-function.factory.ts.html +145 -0
- package/coverage/lcov-report/platform/register-trigger-handler.factory.ts.html +214 -0
- package/coverage/lcov-report/platform/security-context.ts.html +127 -0
- package/coverage/lcov-report/platform/startup.service.ts.html +106 -0
- package/coverage/lcov-report/platform/system-logger-name.provider.ts.html +145 -0
- package/coverage/lcov-report/platform/system.container.ts.html +169 -0
- package/coverage/lcov-report/platform-context.model.ts.html +124 -0
- package/coverage/lcov-report/platform.logger.ts.html +316 -0
- package/coverage/lcov-report/platform.model.ts.html +292 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/security/index.html +146 -0
- package/coverage/lcov-report/security/index.ts.html +91 -0
- package/coverage/lcov-report/security/security-context.ts.html +130 -0
- package/coverage/lcov-report/security/security.model.ts.html +169 -0
- package/coverage/lcov-report/shared/all-settled.util.ts.html +118 -0
- package/coverage/lcov-report/shared/decorators/decorators.model.ts.html +136 -0
- package/coverage/lcov-report/shared/decorators/decorators.ts.html +346 -0
- package/coverage/lcov-report/shared/decorators/index.html +146 -0
- package/coverage/lcov-report/shared/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/shared/function-handler-metadata.reader.ts.html +172 -0
- package/coverage/lcov-report/shared/index.html +176 -0
- package/coverage/lcov-report/shared/index.ts.html +133 -0
- package/coverage/lcov-report/shared/ioc-container.utils.ts.html +115 -0
- package/coverage/lcov-report/shared/platform-context-local-storage.ts.html +133 -0
- package/coverage/lcov-report/shared/platform-context.manager.ts.html +253 -0
- package/coverage/lcov-report/shared/platform.context.provider.ts.html +136 -0
- package/coverage/lcov-report/shared/platform.model.ts.html +298 -0
- package/coverage/lcov-report/shared/security.model.ts.html +142 -0
- package/coverage/lcov-report/shared/trie-search.service.ts.html +337 -0
- package/coverage/lcov-report/shared/trigger-handler-metadata.reader.ts.html +166 -0
- package/coverage/lcov-report/shared/zod-parser-wrapper.service.ts.html +217 -0
- package/coverage/lcov-report/shared/zod-parser-wrapper.ts.html +232 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/context/index.html +191 -0
- package/coverage/lcov-report/src/context/index.ts.html +97 -0
- package/coverage/lcov-report/src/context/platform-context.manager.ts.html +193 -0
- package/coverage/lcov-report/src/context/platform-context.model.ts.html +262 -0
- package/coverage/lcov-report/src/context/platform-context.provider.ts.html +196 -0
- package/coverage/lcov-report/src/context/platform.execution.context.ts.html +217 -0
- package/coverage/lcov-report/src/context/wrapped-invocation-context.ts.html +163 -0
- package/coverage/lcov-report/src/event-hub-handler/azure-event-hub-trigger.model.ts.html +187 -0
- package/coverage/lcov-report/src/event-hub-handler/azure-event-hub-trigger.service.ts.html +769 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/decorators.model.ts.html +313 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/decorators.ts.html +778 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/index.html +146 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handle-method-args-metadata.service.ts.html +130 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler-metadata.reader.ts.html +199 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler-registration.service.ts.html +220 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler.factory.ts.html +283 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler.model.ts.html +421 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler.provider.ts.html +187 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger-support.factory.ts.html +787 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger-support.service.ts.html +832 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger.model.ts.html +193 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger.service.ts.html +859 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-triggers-registration.service.ts.html +307 -0
- package/coverage/lcov-report/src/event-hub-handler/index.html +221 -0
- package/coverage/lcov-report/src/event-hub-handler/index.ts.html +142 -0
- package/coverage/lcov-report/src/framework.container.ts.html +157 -0
- package/coverage/lcov-report/src/http-controller/authentication.provider.ts.html +481 -0
- package/coverage/lcov-report/src/http-controller/authenticator.provider.ts.html +460 -0
- package/coverage/lcov-report/src/http-controller/azure-http-trigger.service.ts.html +865 -0
- package/coverage/lcov-report/src/http-controller/decorators/decorators.model.ts.html +553 -0
- package/coverage/lcov-report/src/http-controller/decorators/decorators.ts.html +1633 -0
- package/coverage/lcov-report/src/http-controller/decorators/index.html +146 -0
- package/coverage/lcov-report/src/http-controller/decorators/index.ts.html +94 -0
- package/coverage/lcov-report/src/http-controller/http-controller-metadata.reader.ts.html +271 -0
- package/coverage/lcov-report/src/http-controller/http-controller-metadata.service.ts.html +121 -0
- package/coverage/lcov-report/src/http-controller/http-controller-platform.model.ts.html +187 -0
- package/coverage/lcov-report/src/http-controller/http-controller-registration.service.ts.html +241 -0
- package/coverage/lcov-report/src/http-controller/http-controller.model.ts.html +784 -0
- package/coverage/lcov-report/src/http-controller/http-handler-support.factory.ts.html +481 -0
- package/coverage/lcov-report/src/http-controller/http-handler.factory.ts.html +406 -0
- package/coverage/lcov-report/src/http-controller/http-operation-registration.service.ts.html +328 -0
- package/coverage/lcov-report/src/http-controller/http-operations-registration.service.ts.html +328 -0
- package/coverage/lcov-report/src/http-controller/http-request-arg-provider.factory.ts.html +580 -0
- package/coverage/lcov-report/src/http-controller/http-request-handler.provider.ts.html +388 -0
- package/coverage/lcov-report/src/http-controller/http-response-processor.factory.ts.html +316 -0
- package/coverage/lcov-report/src/http-controller/index.html +311 -0
- package/coverage/lcov-report/src/http-controller/index.ts.html +226 -0
- package/coverage/lcov-report/src/http-controller/open-api-definition.service.ts.html +550 -0
- package/coverage/lcov-report/src/http-controller/open-api-metadata.service.ts.html +373 -0
- package/coverage/lcov-report/src/http-controller/open-api-print.service.ts.html +232 -0
- package/coverage/lcov-report/src/http-controller/open-api-registration.service.ts.html +220 -0
- package/coverage/lcov-report/src/http-controller/rest-open-api.regstry.ts.html +262 -0
- package/coverage/lcov-report/src/http-controller/security/authentication-service.factory.ts.html +280 -0
- package/coverage/lcov-report/src/http-controller/security/authentication-service.ts.html +139 -0
- package/coverage/lcov-report/src/http-controller/security/authenticator.provider.ts.html +799 -0
- package/coverage/lcov-report/src/http-controller/security/bearer-security-authentication.service.ts.html +133 -0
- package/coverage/lcov-report/src/http-controller/security/index.html +206 -0
- package/coverage/lcov-report/src/http-controller/security/index.ts.html +94 -0
- package/coverage/lcov-report/src/http-controller/security/model.ts.html +133 -0
- package/coverage/lcov-report/src/http-controller/security/operation-authentication.resolver.ts.html +418 -0
- package/coverage/lcov-report/src/http-controller/security/principal-merge.service.ts.html +163 -0
- package/coverage/lcov-report/src/http-controller/security/strict-principal-merge.servce.ts.html +154 -0
- package/coverage/lcov-report/src/http-controller/swagger-handling.service.ts.html +463 -0
- package/coverage/lcov-report/src/index.html +161 -0
- package/coverage/lcov-report/src/init.ts.html +97 -0
- package/coverage/lcov-report/src/logger/azure-log-transport.service.ts.html +433 -0
- package/coverage/lcov-report/src/logger/bindings.ts.html +253 -0
- package/coverage/lcov-report/src/logger/index.html +221 -0
- package/coverage/lcov-report/src/logger/index.ts.html +163 -0
- package/coverage/lcov-report/src/logger/log-level.service.ts.html +127 -0
- package/coverage/lcov-report/src/logger/log-transport.service.ts.html +571 -0
- package/coverage/lcov-report/src/logger/logger-factory.provider.ts.html +142 -0
- package/coverage/lcov-report/src/logger/logger.factory.ts.html +172 -0
- package/coverage/lcov-report/src/logger/logger.model.ts.html +868 -0
- package/coverage/lcov-report/src/logger/logger.utils.ts.html +877 -0
- package/coverage/lcov-report/src/logger/otel.logger.ts.html +358 -0
- package/coverage/lcov-report/src/logger/platform.logger.ts.html +229 -0
- package/coverage/lcov-report/src/logger/trie-search.service.ts.html +616 -0
- package/coverage/lcov-report/src/middleware.ts.html +232 -0
- package/coverage/lcov-report/src/platform/azure-platform.ts.html +256 -0
- package/coverage/lcov-report/src/platform/index.html +176 -0
- package/coverage/lcov-report/src/platform/index.ts.html +139 -0
- package/coverage/lcov-report/src/platform/platform-component-metadata.service.ts.html +115 -0
- package/coverage/lcov-report/src/platform/register-function.factory.ts.html +145 -0
- package/coverage/lcov-report/src/platform/register-trigger-handler.factory.ts.html +214 -0
- package/coverage/lcov-report/src/platform/security-context.ts.html +127 -0
- package/coverage/lcov-report/src/platform/startup.service.ts.html +202 -0
- package/coverage/lcov-report/src/platform/system-logger-name.provider.ts.html +145 -0
- package/coverage/lcov-report/src/platform/system.container.ts.html +172 -0
- package/coverage/lcov-report/src/platform.container.ts.html +148 -0
- package/coverage/lcov-report/src/security/index.html +146 -0
- package/coverage/lcov-report/src/security/index.ts.html +91 -0
- package/coverage/lcov-report/src/security/security-context.ts.html +175 -0
- package/coverage/lcov-report/src/security/security.model.ts.html +223 -0
- package/coverage/lcov-report/src/shared/decorators/decorators.model.ts.html +136 -0
- package/coverage/lcov-report/src/shared/decorators/decorators.ts.html +346 -0
- package/coverage/lcov-report/src/shared/decorators/index.html +146 -0
- package/coverage/lcov-report/src/shared/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/src/shared/index.html +176 -0
- package/coverage/lcov-report/src/shared/index.ts.html +133 -0
- package/coverage/lcov-report/src/shared/ioc-container.utils.ts.html +115 -0
- package/coverage/lcov-report/src/shared/platform-context-local-storage.ts.html +133 -0
- package/coverage/lcov-report/src/shared/platform.model.ts.html +298 -0
- package/coverage/lcov-report/src/shared/security.model.ts.html +139 -0
- package/coverage/lcov-report/src/shared/trie-search.service.ts.html +337 -0
- package/coverage/lcov-report/src/shared/trigger-handler-metadata.reader.ts.html +166 -0
- package/coverage/lcov-report/src/shared/zod-parser-wrapper.ts.html +232 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov-report/test/utils.ts.html +100 -0
- package/coverage/lcov-report/test-utils/index.html +116 -0
- package/coverage/lcov-report/test-utils/utils.ts.html +100 -0
- package/coverage/lcov-report/trie-search.service.ts.html +469 -0
- package/coverage/lcov-report/trigger-handler-metadata.reader.ts.html +187 -0
- package/coverage/lcov-report/wrapped-invocation-context.ts.html +163 -0
- package/coverage/lcov-report/zod-parser-wrapper.ts.html +232 -0
- package/coverage/lcov.info +3220 -0
- package/dist/assets/swagger-ui/LICENSE +202 -0
- package/dist/assets/swagger-ui/NOTICE +2 -0
- package/dist/assets/swagger-ui/README.md +40 -0
- package/dist/assets/swagger-ui/absolute-path.js +1 -0
- package/dist/assets/swagger-ui/favicon-16x16.png +0 -0
- package/dist/assets/swagger-ui/favicon-32x32.png +0 -0
- package/dist/assets/swagger-ui/index.css +16 -0
- package/dist/assets/swagger-ui/index.html +19 -0
- package/dist/assets/swagger-ui/index.js +1 -0
- package/dist/assets/swagger-ui/log.bundle-sizes.swagger-ui.txt +114 -0
- package/dist/assets/swagger-ui/log.es-bundle-core-sizes.swagger-ui.txt +14 -0
- package/dist/assets/swagger-ui/log.es-bundle-sizes.swagger-ui.txt +114 -0
- package/dist/assets/swagger-ui/oauth2-redirect.html +6 -0
- package/dist/assets/swagger-ui/oauth2-redirect.js +1 -0
- package/dist/assets/swagger-ui/package.json +20 -0
- package/dist/assets/swagger-ui/swagger-initializer.js +1 -0
- package/dist/assets/swagger-ui/swagger-ui-bundle.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-bundle.js.LICENSE.txt +106 -0
- package/dist/assets/swagger-ui/swagger-ui-bundle.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle-core.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle-core.js.LICENSE.txt +35 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle-core.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle.js.LICENSE.txt +106 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui-standalone-preset.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-standalone-preset.js.LICENSE.txt +22 -0
- package/dist/assets/swagger-ui/swagger-ui-standalone-preset.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui.css +3 -0
- package/dist/assets/swagger-ui/swagger-ui.css.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui.js +1 -0
- package/dist/assets/swagger-ui/swagger-ui.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.LICENSE.txt +24 -0
- package/dist/src/context/index.d.ts +4 -0
- package/dist/src/context/platform-context.manager.d.ts +23 -0
- package/dist/src/context/platform-context.model.d.ts +56 -0
- package/dist/src/context/platform-context.provider.d.ts +23 -0
- package/dist/src/context/platform.execution.context.d.ts +13 -0
- package/dist/src/context/wrapped-invocation-context.d.ts +5 -0
- package/dist/src/event-hub-handler/decorators/decorators.d.ts +161 -0
- package/dist/src/event-hub-handler/decorators/decorators.model.d.ts +62 -0
- package/dist/src/event-hub-handler/decorators/index.d.ts +2 -0
- package/dist/src/event-hub-handler/event-hub-handler-metadata.reader.d.ts +8 -0
- package/dist/src/event-hub-handler/event-hub-handler-registration.service.d.ts +12 -0
- package/dist/src/event-hub-handler/event-hub-handler.factory.d.ts +13 -0
- package/dist/src/event-hub-handler/event-hub-handler.model.d.ts +101 -0
- package/dist/src/event-hub-handler/event-hub-trigger-support.factory.d.ts +10 -0
- package/dist/src/event-hub-handler/event-hub-trigger.model.d.ts +39 -0
- package/dist/src/event-hub-handler/event-hub-triggers-registration.service.d.ts +18 -0
- package/dist/src/event-hub-handler/index.d.ts +4 -0
- package/dist/src/framework.container.d.ts +6 -0
- package/dist/src/http-controller/decorators/decorators.d.ts +410 -0
- package/dist/src/http-controller/decorators/decorators.model.d.ts +123 -0
- package/dist/src/http-controller/decorators/index.d.ts +3 -0
- package/dist/src/http-controller/http-controller-metadata.reader.d.ts +8 -0
- package/dist/src/http-controller/http-controller-registration.service.d.ts +12 -0
- package/dist/src/http-controller/http-controller.model.d.ts +131 -0
- package/dist/src/http-controller/http-handler-support.factory.d.ts +26 -0
- package/dist/src/http-controller/http-handler.factory.d.ts +16 -0
- package/dist/src/http-controller/http-operations-registration.service.d.ts +22 -0
- package/dist/src/http-controller/http-request-arg-provider.factory.d.ts +12 -0
- package/dist/src/http-controller/http-response-processor.factory.d.ts +10 -0
- package/dist/src/http-controller/index.d.ts +11 -0
- package/dist/src/http-controller/open-api-definition.service.d.ts +29 -0
- package/dist/src/http-controller/open-api-metadata.service.d.ts +11 -0
- package/dist/src/http-controller/open-api-print.service.d.ts +8 -0
- package/dist/src/http-controller/open-api-registration.service.d.ts +17 -0
- package/dist/src/http-controller/security/authentication-service.d.ts +15 -0
- package/dist/src/http-controller/security/authenticator.provider.d.ts +31 -0
- package/dist/src/http-controller/security/bearer-security-authentication.service.d.ts +9 -0
- package/dist/src/http-controller/security/bearer-token.service.d.ts +5 -0
- package/dist/src/http-controller/security/index.d.ts +3 -0
- package/dist/src/http-controller/security/operation-authentication.resolver.d.ts +18 -0
- package/dist/src/http-controller/security/principal-merge.service.d.ts +11 -0
- package/dist/src/http-controller/security/strict-principal-merge.servce.d.ts +5 -0
- package/dist/src/http-controller/swagger-handling.service.d.ts +11 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/init.d.ts +1 -0
- package/dist/src/logger/bindings.d.ts +7 -0
- package/dist/src/logger/index.d.ts +6 -0
- package/dist/src/logger/log-level.service.d.ts +7 -0
- package/dist/src/logger/log-transport.service.d.ts +19 -0
- package/dist/src/logger/logger.model.d.ts +241 -0
- package/dist/src/logger/logger.utils.d.ts +17 -0
- package/dist/src/logger/otel.logger.d.ts +9 -0
- package/dist/src/logger/trie-search.service.d.ts +65 -0
- package/dist/src/middleware.d.ts +10 -0
- package/dist/src/platform/azure-platform.d.ts +15 -0
- package/dist/src/platform/index.d.ts +5 -0
- package/dist/src/platform/model.d.ts +18 -0
- package/dist/src/platform/register-trigger-handler.factory.d.ts +5 -0
- package/dist/src/platform/startup.service.d.ts +36 -0
- package/dist/src/platform/system-logger-name.provider.d.ts +1 -0
- package/dist/src/platform.container.d.ts +3 -0
- package/dist/src/security/index.d.ts +2 -0
- package/dist/src/security/security-context.d.ts +22 -0
- package/dist/src/security/security.model.d.ts +37 -0
- package/dist/src/shared/decorators/decorators.d.ts +37 -0
- package/dist/src/shared/decorators/decorators.model.d.ts +13 -0
- package/dist/src/shared/decorators/index.d.ts +2 -0
- package/dist/src/shared/index.d.ts +8 -0
- package/dist/src/shared/ioc-container.utils.d.ts +7 -0
- package/dist/src/shared/platform.model.d.ts +44 -0
- package/dist/src/shared/trigger-handler-metadata.reader.d.ts +6 -0
- package/dist/src/shared/zod-parser-wrapper.d.ts +5 -0
- package/docs/logging.md +805 -0
- package/package.json +87 -0
- package/src/context/index.ts +4 -0
- package/src/context/platform-context.manager.ts +36 -0
- package/src/context/platform-context.model.ts +59 -0
- package/src/context/platform-context.provider.ts +37 -0
- package/src/context/platform.execution.context.ts +44 -0
- package/src/context/wrapped-invocation-context.ts +26 -0
- package/src/event-hub-handler/decorators/decorators.model.ts +76 -0
- package/src/event-hub-handler/decorators/decorators.ts +231 -0
- package/src/event-hub-handler/decorators/index.ts +2 -0
- package/src/event-hub-handler/event-hub-handler-metadata.reader.ts +38 -0
- package/src/event-hub-handler/event-hub-handler-registration.service.ts +45 -0
- package/src/event-hub-handler/event-hub-handler.factory.ts +66 -0
- package/src/event-hub-handler/event-hub-handler.model.ts +112 -0
- package/src/event-hub-handler/event-hub-trigger-support.factory.ts +234 -0
- package/src/event-hub-handler/event-hub-trigger.model.ts +36 -0
- package/src/event-hub-handler/event-hub-triggers-registration.service.ts +74 -0
- package/src/event-hub-handler/index.ts +19 -0
- package/src/framework.container.ts +24 -0
- package/src/http-controller/decorators/decorators.model.ts +156 -0
- package/src/http-controller/decorators/decorators.ts +516 -0
- package/src/http-controller/decorators/index.ts +3 -0
- package/src/http-controller/http-controller-metadata.reader.ts +62 -0
- package/src/http-controller/http-controller-registration.service.ts +52 -0
- package/src/http-controller/http-controller.model.ts +233 -0
- package/src/http-controller/http-handler-support.factory.ts +132 -0
- package/src/http-controller/http-handler.factory.ts +107 -0
- package/src/http-controller/http-operations-registration.service.ts +81 -0
- package/src/http-controller/http-request-arg-provider.factory.ts +165 -0
- package/src/http-controller/http-response-processor.factory.ts +77 -0
- package/src/http-controller/index.ts +47 -0
- package/src/http-controller/open-api-definition.service.ts +155 -0
- package/src/http-controller/open-api-metadata.service.ts +96 -0
- package/src/http-controller/open-api-print.service.ts +49 -0
- package/src/http-controller/open-api-registration.service.ts +45 -0
- package/src/http-controller/security/authentication-service.ts +18 -0
- package/src/http-controller/security/authenticator.provider.ts +238 -0
- package/src/http-controller/security/bearer-security-authentication.service.ts +16 -0
- package/src/http-controller/security/bearer-token.service.ts +6 -0
- package/src/http-controller/security/index.ts +3 -0
- package/src/http-controller/security/operation-authentication.resolver.ts +111 -0
- package/src/http-controller/security/principal-merge.service.ts +26 -0
- package/src/http-controller/security/strict-principal-merge.servce.ts +23 -0
- package/src/http-controller/swagger-handling.service.ts +126 -0
- package/src/index.ts +80 -0
- package/src/init.ts +4 -0
- package/src/logger/bindings.ts +56 -0
- package/src/logger/index.ts +26 -0
- package/src/logger/log-level.service.ts +14 -0
- package/src/logger/log-transport.service.ts +162 -0
- package/src/logger/logger.model.ts +261 -0
- package/src/logger/logger.utils.ts +264 -0
- package/src/logger/otel.logger.ts +91 -0
- package/src/logger/trie-search.service.ts +177 -0
- package/src/middleware.ts +49 -0
- package/src/platform/azure-platform.ts +57 -0
- package/src/platform/index.ts +18 -0
- package/src/platform/model.ts +19 -0
- package/src/platform/register-trigger-handler.factory.ts +43 -0
- package/src/platform/startup.service.ts +39 -0
- package/src/platform/system-logger-name.provider.ts +20 -0
- package/src/platform.container.ts +21 -0
- package/src/security/index.ts +2 -0
- package/src/security/security-context.ts +30 -0
- package/src/security/security.model.ts +46 -0
- package/src/shared/decorators/decorators.model.ts +17 -0
- package/src/shared/decorators/decorators.ts +87 -0
- package/src/shared/decorators/index.ts +2 -0
- package/src/shared/index.ts +16 -0
- package/src/shared/ioc-container.utils.ts +10 -0
- package/src/shared/platform.model.ts +71 -0
- package/src/shared/trigger-handler-metadata.reader.ts +27 -0
- package/src/shared/zod-parser-wrapper.ts +49 -0
- package/src/test-utilities/index.ts +1 -0
- package/src/test-utilities/utils.ts +5 -0
- package/tsconfig.test.json +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
# @herrromich/az-functions
|
|
2
|
+
|
|
3
|
+
**az-functions** extension for Azure Functions in Node.js
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/%40herrromich%2Faz-functions) [](https://www.npmjs.com/package/@herrromich/az-functions) [](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
**az-functions** extends the Azure Functions programming model for Node.js (v4) by introducing a powerful structure for building scalable and maintainable serverless applications.
|
|
10
|
+
It integrates several key concepts:
|
|
11
|
+
|
|
12
|
+
- **Inversion of Control (IoC) Container:**
|
|
13
|
+
Using [InversifyJS](https://inversify.io/) to manage dependencies and ensure proper decoupling of components.
|
|
14
|
+
- **TypeScript Decorators:**
|
|
15
|
+
Declaratively define HTTP controllers, Event Hub handlers, and their arguments using decorators.
|
|
16
|
+
- **Input Validation:**
|
|
17
|
+
Integrating the [Zod](https://zod.dev/) validation library to ensure that all inputs (e.g., HTTP request bodies, Event Hub messages) are properly validated before processing.
|
|
18
|
+
- **OpenAPI Code-First Generation:**
|
|
19
|
+
Automatically generating OpenAPI (Swagger) definitions based on the controller code, following a code-first approach.
|
|
20
|
+
- **Structured Logging:**
|
|
21
|
+
Built-in logging via [Winston](https://github.com/winstonjs/winston) with optional OpenTelemetry / Application Insights export.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add @herrromich/az-functions @azure/functions inversify reflect-metadata zod @asteasolutions/zod-to-openapi
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @herrromich/az-functions @azure/functions inversify reflect-metadata zod @asteasolutions/zod-to-openapi
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
yarn add @herrromich/az-functions @azure/functions inversify reflect-metadata zod @asteasolutions/zod-to-openapi
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> `@azure/functions`, `inversify`, `reflect-metadata`,`zod` and `@asteasolutions/zod-to-openapi` are peer dependencies and must be installed alongside the package.
|
|
38
|
+
|
|
39
|
+
**az-functions** uses TypeScript decorators.
|
|
40
|
+
Configure your `tsconfig.json` accordingly:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"compilerOptions": {
|
|
45
|
+
"experimentalDecorators": true,
|
|
46
|
+
"emitDecoratorMetadata": true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### Step 1. Initialize `reflect-metadata` and optionally Zod for OpenAPI
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// src/init.ts
|
|
57
|
+
import 'reflect-metadata';
|
|
58
|
+
|
|
59
|
+
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
60
|
+
import { z } from 'zod';
|
|
61
|
+
|
|
62
|
+
extendZodWithOpenApi(z);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Step 2. Define trigger handler classes
|
|
66
|
+
|
|
67
|
+
Define your HTTP controllers and/or Event Hub handlers using decorators (see sections below).
|
|
68
|
+
|
|
69
|
+
### Step 3. Start the platform
|
|
70
|
+
|
|
71
|
+
Call `startPlatform` with a `PlatformConfiguration` object.
|
|
72
|
+
The framework creates and manages the IoC container internally — you provide your `ContainerModule[]` and trigger handler classes:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
// src/index.ts
|
|
76
|
+
import './init';
|
|
77
|
+
|
|
78
|
+
import { startPlatform, OtelConfiguration } from '@herrromich/az-functions';
|
|
79
|
+
import { OrdersController } from './controllers/orders.controller';
|
|
80
|
+
import { TruckTelemetryHandler } from './handlers/truck-telemetry.handler';
|
|
81
|
+
import { AppConfigModule } from './modules/app-config';
|
|
82
|
+
import { PersistenceModule } from './modules/persistence';
|
|
83
|
+
import { SecurityModule } from './modules/security';
|
|
84
|
+
import { ORDERS_REST_APPLICATION } from './applications/orders-api.application';
|
|
85
|
+
|
|
86
|
+
const otelConfiguration: OtelConfiguration | undefined =
|
|
87
|
+
process.env.APPLICATIONINSIGHTS_CONNECTION_STRING !== undefined
|
|
88
|
+
? {
|
|
89
|
+
applicationInsightsConnectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING,
|
|
90
|
+
serviceName: process.env.WEBSITE_DEPLOYMENT_ID,
|
|
91
|
+
serviceVersion: '1.0.0',
|
|
92
|
+
serviceInstanceId: process.env.WEBSITE_INSTANCE_ID,
|
|
93
|
+
}
|
|
94
|
+
: undefined;
|
|
95
|
+
|
|
96
|
+
startPlatform({
|
|
97
|
+
triggerHandlerClasses: [OrdersController, TruckTelemetryHandler],
|
|
98
|
+
restApplications: [ORDERS_REST_APPLICATION],
|
|
99
|
+
modules: [AppConfigModule, PersistenceModule, SecurityModule],
|
|
100
|
+
loggerConfiguration: {
|
|
101
|
+
otelConfiguration,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> [!WARNING]
|
|
107
|
+
> If you use a bundler like **webpack**, make sure the `init` import is at the very top of your entry module.
|
|
108
|
+
|
|
109
|
+
#### `PlatformConfiguration`
|
|
110
|
+
|
|
111
|
+
| Property | Type | Description |
|
|
112
|
+
|--------------------------|--------------------------|------------------------------------------------------------------------|
|
|
113
|
+
| `triggerHandlerClasses` | `TriggerHandlerClass[]` | HTTP controller and Event Hub handler classes to register. |
|
|
114
|
+
| `restApplications` | `RestApplication[]` | Optional REST application definitions (OpenAPI config, context path). |
|
|
115
|
+
| `modules` | `ContainerModule[]` | Inversify container modules loaded into the platform container. |
|
|
116
|
+
| `loggerConfiguration` | `LoggerConfiguration` | Optional logger and OpenTelemetry configuration. |
|
|
117
|
+
|
|
118
|
+
## HTTP Controller
|
|
119
|
+
|
|
120
|
+
### Define a REST Application (optional)
|
|
121
|
+
|
|
122
|
+
A `RestApplication` defines the OpenAPI metadata and base context path for a group of controllers.
|
|
123
|
+
If omitted, the platform generates a default OpenAPI definition with available endpoints.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
// src/applications/orders-api.application.ts
|
|
127
|
+
import { RestApplication } from '@herrromich/az-functions';
|
|
128
|
+
|
|
129
|
+
export const ORDERS_API = 'orders-api';
|
|
130
|
+
|
|
131
|
+
export const ORDERS_REST_APPLICATION: RestApplication = {
|
|
132
|
+
name: ORDERS_API,
|
|
133
|
+
context: 'orders-api',
|
|
134
|
+
openApiConfig: {
|
|
135
|
+
openapi: '3.0.1',
|
|
136
|
+
info: {
|
|
137
|
+
title: 'Orders API',
|
|
138
|
+
version: '1.0.0',
|
|
139
|
+
description: 'API for Orders Management',
|
|
140
|
+
},
|
|
141
|
+
tags: [
|
|
142
|
+
{ name: 'Orders', description: 'CRUD operations for orders' },
|
|
143
|
+
],
|
|
144
|
+
security: [{ bearerAuth: [] }],
|
|
145
|
+
components: {
|
|
146
|
+
securitySchemes: {
|
|
147
|
+
bearerAuth: {
|
|
148
|
+
type: 'http',
|
|
149
|
+
scheme: 'bearer',
|
|
150
|
+
bearerFormat: 'JWT',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Define an HTTP Controller
|
|
159
|
+
|
|
160
|
+
Use `@HttpController` (class decorator) and HTTP method decorators (`@Get`, `@Post`, `@Put`, `@Patch`, `@Delete`, `@Head`) to define routes.
|
|
161
|
+
Parameter decorators inject validated request data:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// src/controllers/orders.controller.ts
|
|
165
|
+
import { z } from 'zod';
|
|
166
|
+
import { inject } from 'inversify';
|
|
167
|
+
import {
|
|
168
|
+
AuthContext,
|
|
169
|
+
AuthCtx,
|
|
170
|
+
BadRequestError,
|
|
171
|
+
Body,
|
|
172
|
+
Get,
|
|
173
|
+
HttpController,
|
|
174
|
+
HttpDirectResponseBuilder,
|
|
175
|
+
Logger,
|
|
176
|
+
LOGGER_FACTORY,
|
|
177
|
+
LoggerFactory,
|
|
178
|
+
NotFoundError,
|
|
179
|
+
NumberSchema,
|
|
180
|
+
Post,
|
|
181
|
+
QueryParam,
|
|
182
|
+
} from '@herrromich/az-functions';
|
|
183
|
+
import { ORDERS_API } from './orders-api.application';
|
|
184
|
+
|
|
185
|
+
const OrderDtoSchema = z.object({
|
|
186
|
+
id: z.string().uuid(),
|
|
187
|
+
customerName: z.string(),
|
|
188
|
+
total: z.number(),
|
|
189
|
+
}).openapi('OrderDto');
|
|
190
|
+
|
|
191
|
+
type OrderDto = z.infer<typeof OrderDtoSchema>;
|
|
192
|
+
|
|
193
|
+
const OrdersResponseSchema = z.object({
|
|
194
|
+
items: z.array(OrderDtoSchema),
|
|
195
|
+
total: z.number(),
|
|
196
|
+
}).openapi('OrdersResponse');
|
|
197
|
+
|
|
198
|
+
type OrdersResponse = z.infer<typeof OrdersResponseSchema>;
|
|
199
|
+
|
|
200
|
+
const OrderCreateRequestSchema = z.object({
|
|
201
|
+
customerId: z.string().uuid(),
|
|
202
|
+
items: z.array(z.object({ productId: z.string(), quantity: z.number() })),
|
|
203
|
+
}).openapi('OrderCreateRequest');
|
|
204
|
+
|
|
205
|
+
type OrderCreateRequest = z.infer<typeof OrderCreateRequestSchema>;
|
|
206
|
+
|
|
207
|
+
@HttpController({
|
|
208
|
+
application: ORDERS_API,
|
|
209
|
+
path: '/orders',
|
|
210
|
+
tags: ['Orders'],
|
|
211
|
+
})
|
|
212
|
+
export class OrdersController {
|
|
213
|
+
private readonly logger: Logger;
|
|
214
|
+
|
|
215
|
+
constructor(
|
|
216
|
+
@inject(LOGGER_FACTORY) loggerFactory: LoggerFactory,
|
|
217
|
+
private readonly ordersRepository: OrdersRepository,
|
|
218
|
+
) {
|
|
219
|
+
this.logger = loggerFactory();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@Get({
|
|
223
|
+
description: 'Get orders with pagination',
|
|
224
|
+
directResponse: {
|
|
225
|
+
status: 200,
|
|
226
|
+
description: 'Paginated list of orders',
|
|
227
|
+
jsonContent: { schema: OrdersResponseSchema },
|
|
228
|
+
},
|
|
229
|
+
})
|
|
230
|
+
async getOrders(
|
|
231
|
+
@AuthCtx() authContext: AuthContext,
|
|
232
|
+
@QueryParam({
|
|
233
|
+
name: 'offset',
|
|
234
|
+
schema: NumberSchema.optional().openapi({ description: 'Items to skip' }),
|
|
235
|
+
})
|
|
236
|
+
offset: number | undefined,
|
|
237
|
+
@QueryParam({
|
|
238
|
+
name: 'limit',
|
|
239
|
+
schema: NumberSchema.optional().openapi({ description: 'Max items to return' }),
|
|
240
|
+
})
|
|
241
|
+
limit: number | undefined,
|
|
242
|
+
): Promise<OrdersResponse> {
|
|
243
|
+
this.logger.info('Fetching orders.');
|
|
244
|
+
// ... fetch and return orders
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@Post({
|
|
248
|
+
description: 'Create a new order',
|
|
249
|
+
directResponse: {
|
|
250
|
+
status: 201,
|
|
251
|
+
description: 'Order created successfully',
|
|
252
|
+
jsonContent: { schema: OrderDtoSchema },
|
|
253
|
+
},
|
|
254
|
+
responses: {
|
|
255
|
+
'400': { description: 'Bad request error' },
|
|
256
|
+
},
|
|
257
|
+
})
|
|
258
|
+
async createOrder(
|
|
259
|
+
@AuthCtx() authContext: AuthContext,
|
|
260
|
+
@Body({
|
|
261
|
+
description: 'Order creation request',
|
|
262
|
+
schema: OrderCreateRequestSchema,
|
|
263
|
+
})
|
|
264
|
+
request: OrderCreateRequest,
|
|
265
|
+
): Promise<HttpResponseInit> {
|
|
266
|
+
this.logger.info('Creating order.');
|
|
267
|
+
const order = await this.ordersRepository.create(request);
|
|
268
|
+
return HttpDirectResponseBuilder.builder<OrderDto>()
|
|
269
|
+
.header('Location', `/orders/${order.id}`)
|
|
270
|
+
.jsonBody(order)
|
|
271
|
+
.build();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### HTTP Decorators Reference
|
|
277
|
+
|
|
278
|
+
#### Class Decorator
|
|
279
|
+
|
|
280
|
+
| Decorator | Config | Description |
|
|
281
|
+
|----------------------------|--------------------|--------------------------------------|
|
|
282
|
+
| `@HttpController(config)` | `ControllerConfig` | Marks a class as an HTTP controller. |
|
|
283
|
+
|
|
284
|
+
**`ControllerConfig`:**
|
|
285
|
+
|
|
286
|
+
| Property | Type | Description |
|
|
287
|
+
|---------------|--------------|--------------------------------------------------------------|
|
|
288
|
+
| `application` | `string?` | Name of the REST application this controller belongs to. |
|
|
289
|
+
| `path` | `string` | Base path for all operations in this controller. |
|
|
290
|
+
| `tags` | `string[]?` | OpenAPI tags for this controller. |
|
|
291
|
+
|
|
292
|
+
#### Method Decorators
|
|
293
|
+
|
|
294
|
+
| Decorator | HTTP Method |
|
|
295
|
+
|--------------------|-------------|
|
|
296
|
+
| `@Get(config?)` | GET |
|
|
297
|
+
| `@Post(config?)` | POST |
|
|
298
|
+
| `@Put(config?)` | PUT |
|
|
299
|
+
| `@Patch(config?)` | PATCH |
|
|
300
|
+
| `@Delete(config?)` | DELETE |
|
|
301
|
+
| `@Head(config?)` | HEAD |
|
|
302
|
+
|
|
303
|
+
Each accepts a `ControllerOperationConfig` (or `ControllerRequestBodyOperationConfig` for POST/PUT/PATCH) with properties like `path`, `description`, `summary`, `directResponse`, `responses`, `authLevel`, etc.
|
|
304
|
+
|
|
305
|
+
#### Parameter Decorators
|
|
306
|
+
|
|
307
|
+
| Decorator | Description |
|
|
308
|
+
|------------------------|----------------------------------------------------------------------------------------------|
|
|
309
|
+
| `@Body(config)` | Injects the validated request body. Config: `{ schema, description?, required?, example? }` |
|
|
310
|
+
| `@QueryParam(config)` | Injects a validated query parameter. Config: `{ name, schema? }` |
|
|
311
|
+
| `@PathParam(config)` | Injects a validated path parameter. Config: `{ name, schema? }` |
|
|
312
|
+
| `@HeaderParam(config)` | Injects a validated header value. Config: `{ name, schema? }` |
|
|
313
|
+
| `@Request()` | Injects the raw `HttpRequest` object. |
|
|
314
|
+
| `@AuthCtx()` | Injects the `AuthContext` with the authenticated principal. |
|
|
315
|
+
|
|
316
|
+
### HTTP Error Classes
|
|
317
|
+
|
|
318
|
+
Throw these from controller methods to return appropriate HTTP error responses:
|
|
319
|
+
|
|
320
|
+
| Class | Status Code |
|
|
321
|
+
|-----------------------|-------------|
|
|
322
|
+
| `BadRequestError` | 400 |
|
|
323
|
+
| `UnauthorizedError` | 401 |
|
|
324
|
+
| `NotFoundError` | 404 |
|
|
325
|
+
| `InternalServerError` | 500 |
|
|
326
|
+
|
|
327
|
+
### `HttpDirectResponseBuilder`
|
|
328
|
+
|
|
329
|
+
Use when you need full control over the HTTP response (custom status, headers):
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
return HttpDirectResponseBuilder.builder<OrderDto>()
|
|
333
|
+
.header('Location', `/orders/${order.id}`)
|
|
334
|
+
.jsonBody(orderDto)
|
|
335
|
+
.build();
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Event Hub Handler
|
|
339
|
+
|
|
340
|
+
### Define an Event Hub Handler
|
|
341
|
+
|
|
342
|
+
Use `@EventHubHandler` (class decorator) to specify the Event Hub connection and name.
|
|
343
|
+
Use `@OnEventHubTrigger` (method decorator) to define the trigger method:
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
// src/handlers/truck-telemetry.handler.ts
|
|
347
|
+
import { z } from 'zod';
|
|
348
|
+
import { inject } from 'inversify';
|
|
349
|
+
import {
|
|
350
|
+
EventHubHandler,
|
|
351
|
+
EventHubMessageWrapper,
|
|
352
|
+
LOGGER_FACTORY,
|
|
353
|
+
LoggerFactory,
|
|
354
|
+
Messages,
|
|
355
|
+
OnEventHubTrigger,
|
|
356
|
+
} from '@herrromich/az-functions';
|
|
357
|
+
|
|
358
|
+
const TelemetryPayloadSchema = z.object({
|
|
359
|
+
deviceId: z.string(),
|
|
360
|
+
temperature: z.number(),
|
|
361
|
+
timestamp: z.string(),
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
type TelemetryPayload = z.infer<typeof TelemetryPayloadSchema>;
|
|
365
|
+
|
|
366
|
+
@EventHubHandler({
|
|
367
|
+
connection: 'EventHubConnection',
|
|
368
|
+
eventHubName: 'telemetry',
|
|
369
|
+
})
|
|
370
|
+
export class TruckTelemetryHandler {
|
|
371
|
+
private readonly logger;
|
|
372
|
+
|
|
373
|
+
constructor(@inject(LOGGER_FACTORY) loggerFactory: LoggerFactory) {
|
|
374
|
+
this.logger = loggerFactory();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
@OnEventHubTrigger({ cardinality: 'many' })
|
|
378
|
+
async handleTelemetry(
|
|
379
|
+
@Messages({
|
|
380
|
+
withPayload: TelemetryPayloadSchema,
|
|
381
|
+
withEventData: true,
|
|
382
|
+
})
|
|
383
|
+
messages: EventHubMessageWrapper<TelemetryPayload, undefined, undefined, true>[],
|
|
384
|
+
): Promise<void> {
|
|
385
|
+
this.logger.info(`Received ${messages.length} telemetry messages`, {
|
|
386
|
+
messages: messages.map(msg => ({
|
|
387
|
+
payload: msg.payload,
|
|
388
|
+
enqueuedTimeUtc: msg.eventData.enqueuedTimeUtc,
|
|
389
|
+
})),
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Event Hub Decorators Reference
|
|
396
|
+
|
|
397
|
+
#### Class Decorator
|
|
398
|
+
|
|
399
|
+
| Decorator | Config | Description |
|
|
400
|
+
|-----------------------------|-------------------------|-----------------------------------------|
|
|
401
|
+
| `@EventHubHandler(config)` | `EventHubHandlerConfig` | Marks a class as an Event Hub handler. |
|
|
402
|
+
|
|
403
|
+
**`EventHubHandlerConfig`:**
|
|
404
|
+
|
|
405
|
+
| Property | Type | Description |
|
|
406
|
+
|----------------|----------|----------------------------------------------------------------|
|
|
407
|
+
| `connection` | `string` | App setting name containing the Event Hub connection string. |
|
|
408
|
+
| `eventHubName` | `string` | Name of the Event Hub to listen to. |
|
|
409
|
+
|
|
410
|
+
#### Method Decorator
|
|
411
|
+
|
|
412
|
+
| Decorator | Config | Description |
|
|
413
|
+
|--------------------------------|---------------------------|----------------------------------------------------------------|
|
|
414
|
+
| `@OnEventHubTrigger(config?)` | `OnEventHubTriggerConfig` | Marks the method that handles incoming Event Hub messages. |
|
|
415
|
+
|
|
416
|
+
**`OnEventHubTriggerConfig`:**
|
|
417
|
+
|
|
418
|
+
| Property | Type | Default | Description |
|
|
419
|
+
|----------------|---------------------|------------|--------------------------------------------------|
|
|
420
|
+
| `triggerId` | `string?` | — | Unique identifier for the trigger. |
|
|
421
|
+
| `consumerGroup`| `string?` | `$Default` | Consumer group to use. |
|
|
422
|
+
| `cardinality` | `'one' \| 'many'?` | `'many'` | Whether to receive a single message or a batch. |
|
|
423
|
+
| `extraInputs` | `FunctionInput[]?` | — | Additional Azure Functions inputs. |
|
|
424
|
+
| `extraOutputs` | `FunctionOutput[]?` | — | Additional Azure Functions outputs. |
|
|
425
|
+
|
|
426
|
+
#### Parameter Decorators
|
|
427
|
+
|
|
428
|
+
| Decorator | Cardinality | Description |
|
|
429
|
+
|----------------------|-------------|--------------------------------------------------|
|
|
430
|
+
| `@Message(config?)` | `one` | Injects a single validated message wrapper. |
|
|
431
|
+
| `@Messages(config?)` | `many` | Injects an array of validated message wrappers. |
|
|
432
|
+
| `@RawMessage()` | `one` | Injects the raw unvalidated message. |
|
|
433
|
+
| `@RawMessages()` | `many` | Injects the raw unvalidated message array. |
|
|
434
|
+
|
|
435
|
+
**`EventHubTriggerMessageArgConfig`** (for `@Message` / `@Messages`):
|
|
436
|
+
|
|
437
|
+
| Property | Type | Description |
|
|
438
|
+
|-------------------------|------------|------------------------------------------------------------------------------|
|
|
439
|
+
| `withPayload` | `ZodType?` | Schema to validate the message payload. |
|
|
440
|
+
| `withProperties` | `ZodType?` | Schema to validate custom properties. |
|
|
441
|
+
| `withSystemProperties` | `ZodType?` | Schema to validate system properties. |
|
|
442
|
+
| `withEventData` | `true?` | Include Event Hub event data (offset, sequence number, enqueued time, etc.). |
|
|
443
|
+
|
|
444
|
+
### `EventHubMessageWrapper<PAYLOAD, PROPERTIES, SYSTEM_PROPERTIES, EVENT_DATA>`
|
|
445
|
+
|
|
446
|
+
The wrapper type provides typed access to message components:
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
message.payload // PAYLOAD — validated message body
|
|
450
|
+
message.properties // PROPERTIES — custom properties (if schema provided)
|
|
451
|
+
message.systemProperties // SYSTEM_PROPERTIES — system properties (if schema provided)
|
|
452
|
+
message.eventData // EventHubEventData — event metadata (if withEventData: true)
|
|
453
|
+
message.valid // boolean — whether validation succeeded
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
## Startup Service
|
|
457
|
+
|
|
458
|
+
Register a startup hook that runs when the Azure Functions host starts:
|
|
459
|
+
|
|
460
|
+
```ts
|
|
461
|
+
import { IStartupService, STARTUP_SERVICE } from '@herrromich/az-functions';
|
|
462
|
+
import { injectable } from 'inversify';
|
|
463
|
+
|
|
464
|
+
@injectable()
|
|
465
|
+
export class MyStartupService implements IStartupService {
|
|
466
|
+
async startup(): Promise<void> {
|
|
467
|
+
// Run migrations, warm caches, etc.
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Register it in a container module:
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
import { ContainerModule } from 'inversify';
|
|
476
|
+
import { STARTUP_SERVICE } from '@herrromich/az-functions';
|
|
477
|
+
import { MyStartupService } from './startup.service';
|
|
478
|
+
|
|
479
|
+
export const StartupModule = new ContainerModule(({ bind }) => {
|
|
480
|
+
bind(STARTUP_SERVICE).to(MyStartupService);
|
|
481
|
+
});
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
## Logging
|
|
485
|
+
|
|
486
|
+
The framework provides a structured logging system built on [Winston](https://github.com/winstonjs/winston).
|
|
487
|
+
It supports automatic logger naming, hierarchical log level configuration, per-invocation context metadata, and optional OpenTelemetry export.
|
|
488
|
+
|
|
489
|
+
### Basic Usage
|
|
490
|
+
|
|
491
|
+
Inject `LOGGER_FACTORY` and call it to create a logger scoped to your class:
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
import { inject } from 'inversify';
|
|
495
|
+
import { Logger, LOGGER_FACTORY, LoggerFactory } from '@herrromich/az-functions';
|
|
496
|
+
|
|
497
|
+
@injectable()
|
|
498
|
+
export class OrdersService {
|
|
499
|
+
private readonly logger: Logger;
|
|
500
|
+
|
|
501
|
+
constructor(@inject(LOGGER_FACTORY) loggerFactory: LoggerFactory) {
|
|
502
|
+
this.logger = loggerFactory(); // auto-detects logger name from the call stack
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
doWork() {
|
|
506
|
+
this.logger.info('Processing started.');
|
|
507
|
+
this.logger.debug('Details:', { someContext: 'value' });
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
You can also provide an explicit logger name:
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
this.logger = loggerFactory('my-app.orders.OrdersService');
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Log Levels
|
|
519
|
+
|
|
520
|
+
The following log levels are available, ordered from highest to lowest severity:
|
|
521
|
+
|
|
522
|
+
| Level | Priority | Description |
|
|
523
|
+
|-----------|----------|------------------------|
|
|
524
|
+
| `error` | 0 | Error conditions |
|
|
525
|
+
| `warn` | 1 | Warning conditions |
|
|
526
|
+
| `info` | 2 | Informational messages |
|
|
527
|
+
| `http` | 3 | HTTP request logging |
|
|
528
|
+
| `verbose` | 4 | Verbose output |
|
|
529
|
+
| `debug` | 5 | Debug information |
|
|
530
|
+
| `silly` | 6 | Trace-level detail |
|
|
531
|
+
|
|
532
|
+
### Logger Interface
|
|
533
|
+
|
|
534
|
+
The `Logger` type exposes a method for each log level.
|
|
535
|
+
Each method accepts a message and optional metadata:
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
logger.error('Operation failed', { orderId, error });
|
|
539
|
+
logger.warn('Retrying request', { attempt: 3 });
|
|
540
|
+
logger.info('Order created', { orderId });
|
|
541
|
+
logger.verbose('Cache hit', { key });
|
|
542
|
+
logger.debug('Query executed', { sql, params });
|
|
543
|
+
logger.silly('Entering method', { args });
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### Default Log Level
|
|
547
|
+
|
|
548
|
+
Set the default log level for all loggers via `LoggerConfiguration`:
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
startPlatform({
|
|
552
|
+
// ...
|
|
553
|
+
loggerConfiguration: {
|
|
554
|
+
defaultLogLevel: 'debug', // default is 'info' if omitted
|
|
555
|
+
},
|
|
556
|
+
});
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
The default log level is set once at startup and applies to all loggers that don't have a specific level configured via `LogLevelProvider`.
|
|
560
|
+
It can be read from the container using the `DEFAULT_LOG_LEVEL` service identifier (e.g., for use in a `LogLevelProvider` constructor).
|
|
561
|
+
|
|
562
|
+
### Per-Logger Log Level Configuration
|
|
563
|
+
|
|
564
|
+
For fine-grained control, implement a `LogLevelProvider` and bind it to `LOG_LEVEL_PROVIDER`.
|
|
565
|
+
The provider receives the logger name and returns the applicable log level (or `undefined` to fall back to the default):
|
|
566
|
+
|
|
567
|
+
```ts
|
|
568
|
+
import { LogLevel, LogLevelProvider, LOG_LEVEL_PROVIDER } from '@herrromich/az-functions';
|
|
569
|
+
import { injectable } from 'inversify';
|
|
570
|
+
|
|
571
|
+
@injectable()
|
|
572
|
+
class MyLogLevelProvider implements LogLevelProvider {
|
|
573
|
+
getLogLevel(loggerName?: string): LogLevel | undefined {
|
|
574
|
+
if (loggerName?.startsWith('my-app.persistence')) {
|
|
575
|
+
return 'error'; // suppress noisy persistence logs
|
|
576
|
+
}
|
|
577
|
+
if (loggerName?.startsWith('my-app.orders')) {
|
|
578
|
+
return 'debug'; // verbose logging for orders module
|
|
579
|
+
}
|
|
580
|
+
return undefined; // use default log level
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export const LoggerModule = new ContainerModule(({ bind }) => {
|
|
585
|
+
bind(LOG_LEVEL_PROVIDER).to(MyLogLevelProvider);
|
|
586
|
+
});
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Hierarchical Log Levels with `TrieSearchService`
|
|
590
|
+
|
|
591
|
+
For applications with many loggers, use the built-in `TrieSearchService` to configure log levels in a hierarchical, prefix-based manner.
|
|
592
|
+
Logger names separated by `.` are matched using a trie — the longest matching prefix wins:
|
|
593
|
+
|
|
594
|
+
```ts
|
|
595
|
+
import {
|
|
596
|
+
DEFAULT_LOG_LEVEL,
|
|
597
|
+
LogLevel,
|
|
598
|
+
LogLevelProvider,
|
|
599
|
+
LOG_LEVEL_PROVIDER,
|
|
600
|
+
SYSTEM_LOGGER_NAME_PREFIX,
|
|
601
|
+
TrieSearchService,
|
|
602
|
+
} from '@herrromich/az-functions';
|
|
603
|
+
import { inject, optional } from 'inversify';
|
|
604
|
+
|
|
605
|
+
export class TrieSearchLogLevelProvider extends TrieSearchService<LogLevel> implements LogLevelProvider {
|
|
606
|
+
constructor(@inject(DEFAULT_LOG_LEVEL) @optional() defaultLogLevel: LogLevel) {
|
|
607
|
+
super('.', defaultLogLevel); // '.' is the separator for hierarchical names
|
|
608
|
+
this.set(SYSTEM_LOGGER_NAME_PREFIX, 'warn'); // platform internals: warn and above
|
|
609
|
+
this.set('my-app.persistence.kysely', 'error'); // Kysely SQL logs: errors only
|
|
610
|
+
this.set('my-app.orders', 'debug'); // orders module: debug and above
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
getLogLevel(loggerName: string | undefined): LogLevel | undefined {
|
|
614
|
+
return this.find(loggerName);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export const LoggerModule = new ContainerModule(({ bind }) => {
|
|
619
|
+
bind(TrieSearchLogLevelProvider).toSelf();
|
|
620
|
+
bind(LOG_LEVEL_PROVIDER).toService(TrieSearchLogLevelProvider);
|
|
621
|
+
});
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
With this configuration:
|
|
625
|
+
|
|
626
|
+
- `my-app.orders.OrdersService` → `debug` (matches `my-app.orders` prefix)
|
|
627
|
+
- `my-app.orders.OrdersMapper` → `debug` (matches `my-app.orders` prefix)
|
|
628
|
+
- `my-app.persistence.kysely` → `error` (exact match)
|
|
629
|
+
- `my-app.persistence.repository` → default level (no specific prefix match)
|
|
630
|
+
- `#az-functions.http-controller` → `warn` (matches `#az-functions` prefix)
|
|
631
|
+
|
|
632
|
+
Since `TrieSearchService` has `set()`, `get()`, and `getAll()` methods, you can also **adjust log levels at runtime**.
|
|
633
|
+
For example, by exposing an HTTP endpoint (see the example project for a full `LogLevelsController` implementation).
|
|
634
|
+
|
|
635
|
+
### Automatic Logger Name Resolution
|
|
636
|
+
|
|
637
|
+
By default, `loggerFactory()` (called without arguments) uses `LOGGER_NAME_PROVIDER` to derive the logger name from the call stack.
|
|
638
|
+
Bind a custom `LOGGER_NAME_PROVIDER` to control how names are derived:
|
|
639
|
+
|
|
640
|
+
```ts
|
|
641
|
+
import { LOGGER_NAME_PROVIDER } from '@herrromich/az-functions';
|
|
642
|
+
|
|
643
|
+
export const LoggerModule = new ContainerModule(({ bind }) => {
|
|
644
|
+
bind(LOGGER_NAME_PROVIDER).toFactory(() => {
|
|
645
|
+
const regexp =
|
|
646
|
+
/^\s*at\s+(?:new\s+)?([A-Za-z0-9_$]+)\s+\(.*src[\\/](.+)\/[^\\/]+:\d+:\d+\)$/;
|
|
647
|
+
return (stackEntry?: string) => {
|
|
648
|
+
const stackLines = stackEntry?.split('\n') ?? [];
|
|
649
|
+
for (const line of stackLines) {
|
|
650
|
+
const match = regexp.exec(line.trim());
|
|
651
|
+
if (match) {
|
|
652
|
+
return `my-app.${match[2]?.replace(/\//g, '.')}.${match[1]}`;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
This produces logger names like `my-app.shared.orders.OrdersService` based on the file path and class name of the caller.
|
|
661
|
+
|
|
662
|
+
### Context Logger Metadata
|
|
663
|
+
|
|
664
|
+
Use `adjustContextLoggerMetadata` to attach metadata to all log messages within the current invocation context.
|
|
665
|
+
Metadata is configured **per log level**, so you can include detailed data only at lower severity levels to avoid noise:
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
import {
|
|
669
|
+
adjustContextLoggerMetadata,
|
|
670
|
+
PLATFORM_CONTEXT_MANAGER,
|
|
671
|
+
} from '@herrromich/az-functions';
|
|
672
|
+
|
|
673
|
+
// Attach metadata scoped to the current invocation context
|
|
674
|
+
adjustContextLoggerMetadata(contextManager, {
|
|
675
|
+
error: {
|
|
676
|
+
// included in error-level messages — full diagnostic data
|
|
677
|
+
requestId,
|
|
678
|
+
userId,
|
|
679
|
+
requestBody,
|
|
680
|
+
},
|
|
681
|
+
warn: {
|
|
682
|
+
// included in warn-level messages — moderate detail
|
|
683
|
+
requestId,
|
|
684
|
+
userId,
|
|
685
|
+
},
|
|
686
|
+
silly: {
|
|
687
|
+
// included in silly-level messages — full trace data
|
|
688
|
+
requestId,
|
|
689
|
+
userId,
|
|
690
|
+
requestBody,
|
|
691
|
+
headers,
|
|
692
|
+
},
|
|
693
|
+
});
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
The metadata is automatically merged with any existing context metadata.
|
|
697
|
+
It is included in all subsequent log messages at the corresponding level within the same invocation.
|
|
698
|
+
|
|
699
|
+
### `SYSTEM_LOGGER_NAME_PREFIX`
|
|
700
|
+
|
|
701
|
+
The constant `SYSTEM_LOGGER_NAME_PREFIX` (`'#az-functions'`) identifies loggers used internally by the platform.
|
|
702
|
+
Use it when configuring log levels to control the verbosity of framework-internal logging separately from your application:
|
|
703
|
+
|
|
704
|
+
```ts
|
|
705
|
+
this.set(SYSTEM_LOGGER_NAME_PREFIX, 'warn'); // only warnings and errors from the framework
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
When an internal (platform) class calls `loggerFactory()` without an explicit name, the name is auto-derived
|
|
709
|
+
from the call stack as `${SYSTEM_LOGGER_NAME_PREFIX}.<module-path>.<ClassName>`, where `<module-path>` mirrors
|
|
710
|
+
the source folder structure inside the package (with `/` replaced by `.`) and `<ClassName>` is the constructor,
|
|
711
|
+
class, or function that requested the logger.
|
|
712
|
+
|
|
713
|
+
Because logger names follow this hierarchical, dot-separated structure, you can use `TrieSearchService`
|
|
714
|
+
(see above) to target a whole subsystem with a single prefix, or a specific class with a fully qualified name.
|
|
715
|
+
|
|
716
|
+
The following internal logger names are currently produced by the platform:
|
|
717
|
+
|
|
718
|
+
| Logger Name | Module / Component |
|
|
719
|
+
|--------------------------------------------------------------------------|--------------------------------------------------------|
|
|
720
|
+
| `#az-functions.platform.AzurePlatform` | Core platform bootstrap / trigger wiring |
|
|
721
|
+
| `#az-functions.http-controller.HttpOperationsRegistrationService` | HTTP operation registration with the Functions host |
|
|
722
|
+
| `#az-functions.http-controller.HttpHandlerFactory` | HTTP trigger handler creation |
|
|
723
|
+
| `#az-functions.http-controller.OpenApiRegistrationService` | OpenAPI route/document registration |
|
|
724
|
+
| `#az-functions.http-controller.OpenApiDefinitionService` | OpenAPI definition generation |
|
|
725
|
+
| `#az-functions.http-controller.OpenApiPrintService` | OpenAPI print (`PLATFORM_MODE=print-open-api`) mode |
|
|
726
|
+
| `#az-functions.http-controller.security.AuthenticatorProvider` | HTTP authenticator resolution |
|
|
727
|
+
| `#az-functions.http-controller.security.OperationAuthenticationResolver` | Per-operation authentication resolution |
|
|
728
|
+
| `#az-functions.event-hub-handler.EventHubTriggersRegistrationService` | Event Hub trigger registration with the Functions host |
|
|
729
|
+
| `#az-functions.event-hub-handler.EventHubHandlerFactory` | Event Hub trigger handler creation |
|
|
730
|
+
|
|
731
|
+
> [!NOTE]
|
|
732
|
+
> This list reflects the classes that currently request a logger via `loggerFactory()` without an explicit
|
|
733
|
+
> name. It may grow as the framework evolves — inspect the resolved logger name via your own `LogLevelProvider`
|
|
734
|
+
> or log output if you need to confirm the exact name for your installed version.
|
|
735
|
+
|
|
736
|
+
### OpenTelemetry / Application Insights
|
|
737
|
+
|
|
738
|
+
Pass `otelConfiguration` in `loggerConfiguration` to export logs and traces to Application Insights:
|
|
739
|
+
|
|
740
|
+
```ts
|
|
741
|
+
startPlatform({
|
|
742
|
+
// ...
|
|
743
|
+
loggerConfiguration: {
|
|
744
|
+
otelConfiguration: {
|
|
745
|
+
applicationInsightsConnectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING,
|
|
746
|
+
serviceName: 'my-service',
|
|
747
|
+
serviceVersion: '1.0.0',
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
});
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
If no `otelConfiguration` is provided, the framework falls back to the built-in Azure Functions `InvocationContext` logger.
|
|
754
|
+
|
|
755
|
+
## OpenAPI Generation
|
|
756
|
+
|
|
757
|
+
If the application can be built, generate the OpenAPI specification in a special mode:
|
|
758
|
+
|
|
759
|
+
```bash
|
|
760
|
+
PLATFORM_MODE=print-open-api node dist/index.js
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
This outputs the OpenAPI JSON and YAML files for each registered REST application without starting the Azure Functions host.
|
|
764
|
+
|
|
765
|
+
| Environment Variable | Default | Description |
|
|
766
|
+
|-----------------------|-----------------------------|--------------------------------------------------------------------------------------------------------|
|
|
767
|
+
| `PLATFORM_MODE` | `start` | Set to `print-open-api` to generate OpenAPI definitions instead of starting the host. |
|
|
768
|
+
| `OPEN_API_PRINT_PATH` | `dist/open-api-definitions` | Directory where generated `.json` and `.yaml` files are written. Resolved relative to `process.cwd()`. |
|
|
769
|
+
|
|
770
|
+
Example with a custom output path:
|
|
771
|
+
|
|
772
|
+
```bash
|
|
773
|
+
PLATFORM_MODE=print-open-api OPEN_API_PRINT_PATH=./docs/api node dist/index.js
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
## Registering Unsupported Azure Functions Triggers
|
|
777
|
+
|
|
778
|
+
For trigger types not yet supported by decorators (e.g., Cosmos DB, Timer), use the Azure Functions SDK directly.
|
|
779
|
+
To benefit from the platform's structured logging and context propagation, retrieve the `PlatformContextManager` and `PlatformContextProvider` from the platform container and wrap your handler execution:
|
|
780
|
+
|
|
781
|
+
```ts
|
|
782
|
+
import { app, InvocationContext } from '@azure/functions';
|
|
783
|
+
import {
|
|
784
|
+
Logger,
|
|
785
|
+
LOGGER_FACTORY,
|
|
786
|
+
LoggerFactory,
|
|
787
|
+
PLATFORM_CONTEXT_MANAGER,
|
|
788
|
+
PLATFORM_CONTEXT_PROVIDER,
|
|
789
|
+
startPlatform,
|
|
790
|
+
} from '@herrromich/az-functions';
|
|
791
|
+
|
|
792
|
+
// startPlatform returns the platform container
|
|
793
|
+
const platformContainer = startPlatform({ /* ... */ });
|
|
794
|
+
|
|
795
|
+
const contextManager = platformContainer.get(PLATFORM_CONTEXT_MANAGER);
|
|
796
|
+
const contextProvider = platformContainer.get(PLATFORM_CONTEXT_PROVIDER);
|
|
797
|
+
const loggerFactory = platformContainer.get(LOGGER_FACTORY);
|
|
798
|
+
const logger: Logger = loggerFactory('cosmosdb-handler');
|
|
799
|
+
|
|
800
|
+
app.cosmosDB('cosmosDbTrigger', {
|
|
801
|
+
connection: 'CosmosDBConnection',
|
|
802
|
+
containerName: 'my-container',
|
|
803
|
+
databaseName: 'my-database',
|
|
804
|
+
handler: async (documents: unknown[], context: InvocationContext) => {
|
|
805
|
+
// Wrap execution in the platform context for structured logging
|
|
806
|
+
return contextManager.runWith(
|
|
807
|
+
contextProvider.providePlatformContext(context),
|
|
808
|
+
async () => {
|
|
809
|
+
logger.info(`Received ${documents.length} documents from Cosmos DB`);
|
|
810
|
+
logger.debug('Processing documents', { documents });
|
|
811
|
+
// ... handle documents
|
|
812
|
+
},
|
|
813
|
+
);
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
**Key services available from the platform container:**
|
|
819
|
+
|
|
820
|
+
| Service Identifier | Type | Description |
|
|
821
|
+
|-----------------------------|---------------------------|---------------------------------------------------------------------------------------------------------|
|
|
822
|
+
| `PLATFORM_CONTEXT_MANAGER` | `PlatformContextManager` | Manages the async context. Use `runWith()` to scope logging and context values to a handler invocation. |
|
|
823
|
+
| `PLATFORM_CONTEXT_PROVIDER` | `PlatformContextProvider` | Creates a `PlatformContext` from an `InvocationContext`. |
|
|
824
|
+
| `LOGGER_FACTORY` | `LoggerFactory` | Creates scoped `Logger` instances with structured logging support. |
|
|
825
|
+
|
|
826
|
+
Without wrapping in `contextManager.runWith()`, the logger will still work but won't have access to the invocation context (e.g., invocation ID, trigger metadata) for log correlation.
|
|
827
|
+
|
|
828
|
+
## License
|
|
829
|
+
|
|
830
|
+
MIT
|