@dyanet/nestjs-config-aws 1.0.1 → 1.2.0-beta.1
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/README.md +208 -1013
- package/dist/cjs/config-aws/src/config-manager.js +366 -0
- package/dist/cjs/config-aws/src/errors/index.js +77 -0
- package/dist/cjs/config-aws/src/index.js +37 -0
- package/dist/cjs/config-aws/src/interfaces/config-loader.interface.js +3 -0
- package/dist/cjs/config-aws/src/interfaces/config-manager.interface.js +3 -0
- package/dist/cjs/config-aws/src/interfaces/env-file-loader.interface.js +3 -0
- package/dist/cjs/config-aws/src/interfaces/environment-loader.interface.js +3 -0
- package/dist/cjs/config-aws/src/interfaces/s3-loader.interface.js +3 -0
- package/dist/cjs/config-aws/src/interfaces/secrets-manager-loader.interface.js +3 -0
- package/dist/cjs/config-aws/src/interfaces/ssm-parameter-store-loader.interface.js +3 -0
- package/dist/cjs/config-aws/src/loaders/env-file.loader.js +169 -0
- package/dist/cjs/config-aws/src/loaders/environment.loader.js +85 -0
- package/dist/cjs/config-aws/src/loaders/s3.loader.js +145 -0
- package/dist/cjs/config-aws/src/loaders/secrets-manager.loader.js +162 -0
- package/dist/cjs/config-aws/src/loaders/ssm-parameter-store.loader.js +199 -0
- package/dist/cjs/config-aws/src/utils/env-file-parser.util.js +98 -0
- package/dist/cjs/config-aws/src/utils/validation.util.js +116 -0
- package/dist/cjs/nestjs-config-aws/src/config.module.js +175 -0
- package/dist/cjs/nestjs-config-aws/src/index.js +61 -0
- package/dist/cjs/{integration → nestjs-config-aws/src/integration}/index.js +1 -1
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/configuration-factory.interface.js +3 -0
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/configuration-source.interface.js +3 -0
- package/dist/cjs/{integration → nestjs-config-aws/src/integration}/interfaces/index.js +1 -1
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/integration-options.interface.js +3 -0
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/integration-state.interface.js +3 -0
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/nestjs-config-compatibility.interface.js +73 -0
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/nestjs-config-integration.interface.js +3 -0
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/typed-configuration.interface.js +4 -0
- package/dist/cjs/nestjs-config-aws/src/integration/interfaces/utility-types.interface.js +52 -0
- package/dist/cjs/nestjs-config-aws/src/integration/nestjs-config-integration.module.js +124 -0
- package/dist/cjs/nestjs-config-aws/src/integration/providers/aws-configuration-loader.service.js +592 -0
- package/dist/cjs/nestjs-config-aws/src/integration/providers/configuration-factory.provider.js +385 -0
- package/dist/cjs/{integration → nestjs-config-aws/src/integration}/providers/index.js +1 -1
- package/dist/cjs/nestjs-config-aws/src/integration/services/async-config-helper.service.js +358 -0
- package/dist/cjs/nestjs-config-aws/src/integration/services/error-handler.service.js +267 -0
- package/dist/cjs/nestjs-config-aws/src/integration/services/factory-registration.service.js +517 -0
- package/dist/cjs/{integration → nestjs-config-aws/src/integration}/services/index.js +1 -1
- package/dist/cjs/nestjs-config-aws/src/integration/services/integration-state.service.js +81 -0
- package/dist/cjs/nestjs-config-aws/src/integration/services/namespace-handler.service.js +465 -0
- package/dist/cjs/nestjs-config-aws/src/integration/services/nestjs-config-integration.service.js +318 -0
- package/dist/cjs/nestjs-config-aws/src/integration/services/precedence-handler.service.js +292 -0
- package/dist/cjs/nestjs-config-aws/src/integration/services/validation-integration.service.js +592 -0
- package/dist/cjs/nestjs-config-aws/src/integration/utils/config-integration.util.js +283 -0
- package/dist/cjs/{integration → nestjs-config-aws/src/integration}/utils/index.js +1 -1
- package/dist/cjs/nestjs-config-aws/src/interfaces/config-service.interface.js +11 -0
- package/dist/cjs/nestjs-config-aws/src/interfaces/default-schema.interface.js +63 -0
- package/dist/cjs/nestjs-config-aws/src/interfaces/index.js +30 -0
- package/dist/cjs/nestjs-config-aws/src/interfaces/module-options.interface.js +3 -0
- package/dist/cjs/nestjs-config-aws/src/services/config.service.js +142 -0
- package/dist/esm/config-aws/src/config-manager.js +362 -0
- package/dist/esm/config-aws/src/errors/index.js +69 -0
- package/dist/esm/config-aws/src/index.js +21 -0
- package/dist/esm/config-aws/src/interfaces/config-loader.interface.js +2 -0
- package/dist/esm/config-aws/src/interfaces/config-manager.interface.js +2 -0
- package/dist/esm/config-aws/src/interfaces/env-file-loader.interface.js +2 -0
- package/dist/esm/config-aws/src/interfaces/environment-loader.interface.js +2 -0
- package/dist/esm/config-aws/src/interfaces/s3-loader.interface.js +2 -0
- package/dist/esm/config-aws/src/interfaces/secrets-manager-loader.interface.js +2 -0
- package/dist/esm/config-aws/src/interfaces/ssm-parameter-store-loader.interface.js +2 -0
- package/dist/esm/config-aws/src/loaders/env-file.loader.js +132 -0
- package/dist/esm/config-aws/src/loaders/environment.loader.js +81 -0
- package/dist/esm/config-aws/src/loaders/s3.loader.js +141 -0
- package/dist/esm/config-aws/src/loaders/secrets-manager.loader.js +158 -0
- package/dist/esm/config-aws/src/loaders/ssm-parameter-store.loader.js +195 -0
- package/dist/esm/config-aws/src/utils/env-file-parser.util.js +94 -0
- package/dist/esm/config-aws/src/utils/validation.util.js +112 -0
- package/dist/esm/nestjs-config-aws/src/config.module.js +172 -0
- package/dist/esm/nestjs-config-aws/src/index.js +23 -0
- package/dist/esm/nestjs-config-aws/src/integration/index.js +7 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/configuration-factory.interface.js +2 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/configuration-source.interface.js +2 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/index.js +10 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/integration-options.interface.js +2 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/integration-state.interface.js +2 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/nestjs-config-compatibility.interface.js +64 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/nestjs-config-integration.interface.js +2 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/typed-configuration.interface.js +3 -0
- package/dist/esm/nestjs-config-aws/src/integration/interfaces/utility-types.interface.js +44 -0
- package/dist/esm/nestjs-config-aws/src/integration/nestjs-config-integration.module.js +121 -0
- package/dist/esm/nestjs-config-aws/src/integration/providers/aws-configuration-loader.service.js +589 -0
- package/dist/esm/nestjs-config-aws/src/integration/providers/configuration-factory.provider.js +382 -0
- package/dist/esm/nestjs-config-aws/src/integration/providers/index.js +4 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/async-config-helper.service.js +355 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/error-handler.service.js +264 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/factory-registration.service.js +514 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/index.js +10 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/integration-state.service.js +78 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/namespace-handler.service.js +462 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/nestjs-config-integration.service.js +315 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/precedence-handler.service.js +289 -0
- package/dist/esm/nestjs-config-aws/src/integration/services/validation-integration.service.js +586 -0
- package/dist/esm/nestjs-config-aws/src/integration/utils/config-integration.util.js +240 -0
- package/dist/esm/nestjs-config-aws/src/integration/utils/index.js +3 -0
- package/dist/esm/nestjs-config-aws/src/interfaces/config-service.interface.js +7 -0
- package/dist/esm/nestjs-config-aws/src/interfaces/default-schema.interface.js +59 -0
- package/dist/esm/nestjs-config-aws/src/interfaces/index.js +8 -0
- package/dist/esm/nestjs-config-aws/src/interfaces/module-options.interface.js +2 -0
- package/dist/esm/nestjs-config-aws/src/services/config.service.js +139 -0
- package/dist/types/config-aws/src/config-manager.d.ts +119 -0
- package/dist/types/config-aws/src/config-manager.d.ts.map +1 -0
- package/dist/types/config-aws/src/errors/index.d.ts +43 -0
- package/dist/types/config-aws/src/errors/index.d.ts.map +1 -0
- package/dist/types/config-aws/src/index.d.ts +24 -0
- package/dist/types/config-aws/src/index.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/config-loader.interface.d.ts +33 -0
- package/dist/types/config-aws/src/interfaces/config-loader.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/config-manager.interface.d.ts +86 -0
- package/dist/types/config-aws/src/interfaces/config-manager.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/env-file-loader.interface.d.ts +12 -0
- package/dist/types/config-aws/src/interfaces/env-file-loader.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/environment-loader.interface.d.ts +10 -0
- package/dist/types/config-aws/src/interfaces/environment-loader.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/s3-loader.interface.d.ts +14 -0
- package/dist/types/config-aws/src/interfaces/s3-loader.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/secrets-manager-loader.interface.d.ts +12 -0
- package/dist/types/config-aws/src/interfaces/secrets-manager-loader.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/interfaces/ssm-parameter-store-loader.interface.d.ts +14 -0
- package/dist/types/config-aws/src/interfaces/ssm-parameter-store-loader.interface.d.ts.map +1 -0
- package/dist/types/config-aws/src/loaders/env-file.loader.d.ts +69 -0
- package/dist/types/config-aws/src/loaders/env-file.loader.d.ts.map +1 -0
- package/dist/types/config-aws/src/loaders/environment.loader.d.ts +46 -0
- package/dist/types/config-aws/src/loaders/environment.loader.d.ts.map +1 -0
- package/dist/types/config-aws/src/loaders/s3.loader.d.ts +62 -0
- package/dist/types/config-aws/src/loaders/s3.loader.d.ts.map +1 -0
- package/dist/types/config-aws/src/loaders/secrets-manager.loader.d.ts +68 -0
- package/dist/types/config-aws/src/loaders/secrets-manager.loader.d.ts.map +1 -0
- package/dist/types/config-aws/src/loaders/ssm-parameter-store.loader.d.ts +78 -0
- package/dist/types/config-aws/src/loaders/ssm-parameter-store.loader.d.ts.map +1 -0
- package/dist/types/config-aws/src/utils/env-file-parser.util.d.ts +45 -0
- package/dist/types/config-aws/src/utils/env-file-parser.util.d.ts.map +1 -0
- package/dist/types/{utils → config-aws/src/utils}/validation.util.d.ts +10 -10
- package/dist/types/config-aws/src/utils/validation.util.d.ts.map +1 -0
- package/dist/types/{config.module.d.ts → nestjs-config-aws/src/config.module.d.ts} +1 -0
- package/dist/types/nestjs-config-aws/src/config.module.d.ts.map +1 -0
- package/dist/types/{index.d.ts → nestjs-config-aws/src/index.d.ts} +2 -4
- package/dist/types/nestjs-config-aws/src/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/configuration-factory.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/configuration-source.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/integration-options.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/integration-state.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/nestjs-config-compatibility.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/nestjs-config-integration.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/typed-configuration.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/interfaces/utility-types.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/nestjs-config-integration.module.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/providers/aws-configuration-loader.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/providers/configuration-factory.provider.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/providers/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/async-config-helper.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/error-handler.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/factory-registration.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/integration-state.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/namespace-handler.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/nestjs-config-integration.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/precedence-handler.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/services/validation-integration.service.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/utils/config-integration.util.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/integration/utils/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/interfaces/config-service.interface.d.ts.map +1 -0
- package/dist/types/{interfaces → nestjs-config-aws/src/interfaces}/default-schema.interface.d.ts +28 -28
- package/dist/types/nestjs-config-aws/src/interfaces/default-schema.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/interfaces/index.d.ts +5 -0
- package/dist/types/nestjs-config-aws/src/interfaces/index.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/interfaces/module-options.interface.d.ts.map +1 -0
- package/dist/types/nestjs-config-aws/src/services/config.service.d.ts +88 -0
- package/dist/types/nestjs-config-aws/src/services/config.service.d.ts.map +1 -0
- package/package.json +17 -24
- package/LICENSE +0 -21
- package/dist/cjs/config.module.js +0 -178
- package/dist/cjs/config.module.js.map +0 -1
- package/dist/cjs/index.js +0 -47
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/integration/index.js.map +0 -1
- package/dist/cjs/integration/interfaces/configuration-factory.interface.js +0 -3
- package/dist/cjs/integration/interfaces/configuration-factory.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/configuration-source.interface.js +0 -3
- package/dist/cjs/integration/interfaces/configuration-source.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/index.js.map +0 -1
- package/dist/cjs/integration/interfaces/integration-options.interface.js +0 -3
- package/dist/cjs/integration/interfaces/integration-options.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/integration-state.interface.js +0 -3
- package/dist/cjs/integration/interfaces/integration-state.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/nestjs-config-compatibility.interface.js +0 -73
- package/dist/cjs/integration/interfaces/nestjs-config-compatibility.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/nestjs-config-integration.interface.js +0 -3
- package/dist/cjs/integration/interfaces/nestjs-config-integration.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/typed-configuration.interface.js +0 -4
- package/dist/cjs/integration/interfaces/typed-configuration.interface.js.map +0 -1
- package/dist/cjs/integration/interfaces/utility-types.interface.js +0 -52
- package/dist/cjs/integration/interfaces/utility-types.interface.js.map +0 -1
- package/dist/cjs/integration/nestjs-config-integration.module.js +0 -124
- package/dist/cjs/integration/nestjs-config-integration.module.js.map +0 -1
- package/dist/cjs/integration/providers/aws-configuration-loader.service.js +0 -591
- package/dist/cjs/integration/providers/aws-configuration-loader.service.js.map +0 -1
- package/dist/cjs/integration/providers/configuration-factory.provider.js +0 -383
- package/dist/cjs/integration/providers/configuration-factory.provider.js.map +0 -1
- package/dist/cjs/integration/providers/index.js.map +0 -1
- package/dist/cjs/integration/services/async-config-helper.service.js +0 -356
- package/dist/cjs/integration/services/async-config-helper.service.js.map +0 -1
- package/dist/cjs/integration/services/error-handler.service.js +0 -265
- package/dist/cjs/integration/services/error-handler.service.js.map +0 -1
- package/dist/cjs/integration/services/factory-registration.service.js +0 -512
- package/dist/cjs/integration/services/factory-registration.service.js.map +0 -1
- package/dist/cjs/integration/services/index.js.map +0 -1
- package/dist/cjs/integration/services/integration-state.service.js +0 -83
- package/dist/cjs/integration/services/integration-state.service.js.map +0 -1
- package/dist/cjs/integration/services/namespace-handler.service.js +0 -467
- package/dist/cjs/integration/services/namespace-handler.service.js.map +0 -1
- package/dist/cjs/integration/services/nestjs-config-integration.service.js +0 -316
- package/dist/cjs/integration/services/nestjs-config-integration.service.js.map +0 -1
- package/dist/cjs/integration/services/precedence-handler.service.js +0 -294
- package/dist/cjs/integration/services/precedence-handler.service.js.map +0 -1
- package/dist/cjs/integration/services/validation-integration.service.js +0 -591
- package/dist/cjs/integration/services/validation-integration.service.js.map +0 -1
- package/dist/cjs/integration/utils/config-integration.util.js +0 -283
- package/dist/cjs/integration/utils/config-integration.util.js.map +0 -1
- package/dist/cjs/integration/utils/index.js.map +0 -1
- package/dist/cjs/interfaces/config-loader.interface.js +0 -3
- package/dist/cjs/interfaces/config-loader.interface.js.map +0 -1
- package/dist/cjs/interfaces/config-service.interface.js +0 -11
- package/dist/cjs/interfaces/config-service.interface.js.map +0 -1
- package/dist/cjs/interfaces/default-schema.interface.js +0 -63
- package/dist/cjs/interfaces/default-schema.interface.js.map +0 -1
- package/dist/cjs/interfaces/errors.interface.js +0 -77
- package/dist/cjs/interfaces/errors.interface.js.map +0 -1
- package/dist/cjs/interfaces/index.js +0 -25
- package/dist/cjs/interfaces/index.js.map +0 -1
- package/dist/cjs/interfaces/module-options.interface.js +0 -3
- package/dist/cjs/interfaces/module-options.interface.js.map +0 -1
- package/dist/cjs/loaders/environment.loader.js +0 -59
- package/dist/cjs/loaders/environment.loader.js.map +0 -1
- package/dist/cjs/loaders/secrets-manager.loader.js +0 -122
- package/dist/cjs/loaders/secrets-manager.loader.js.map +0 -1
- package/dist/cjs/loaders/ssm-parameter-store.loader.js +0 -146
- package/dist/cjs/loaders/ssm-parameter-store.loader.js.map +0 -1
- package/dist/cjs/services/config.service.js +0 -297
- package/dist/cjs/services/config.service.js.map +0 -1
- package/dist/cjs/utils/validation.util.js +0 -114
- package/dist/cjs/utils/validation.util.js.map +0 -1
- package/dist/esm/config.module.js +0 -175
- package/dist/esm/config.module.js.map +0 -1
- package/dist/esm/index.js +0 -18
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/integration/index.js +0 -7
- package/dist/esm/integration/index.js.map +0 -1
- package/dist/esm/integration/interfaces/configuration-factory.interface.js +0 -2
- package/dist/esm/integration/interfaces/configuration-factory.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/configuration-source.interface.js +0 -2
- package/dist/esm/integration/interfaces/configuration-source.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/index.js +0 -10
- package/dist/esm/integration/interfaces/index.js.map +0 -1
- package/dist/esm/integration/interfaces/integration-options.interface.js +0 -2
- package/dist/esm/integration/interfaces/integration-options.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/integration-state.interface.js +0 -2
- package/dist/esm/integration/interfaces/integration-state.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/nestjs-config-compatibility.interface.js +0 -64
- package/dist/esm/integration/interfaces/nestjs-config-compatibility.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/nestjs-config-integration.interface.js +0 -2
- package/dist/esm/integration/interfaces/nestjs-config-integration.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/typed-configuration.interface.js +0 -3
- package/dist/esm/integration/interfaces/typed-configuration.interface.js.map +0 -1
- package/dist/esm/integration/interfaces/utility-types.interface.js +0 -44
- package/dist/esm/integration/interfaces/utility-types.interface.js.map +0 -1
- package/dist/esm/integration/nestjs-config-integration.module.js +0 -121
- package/dist/esm/integration/nestjs-config-integration.module.js.map +0 -1
- package/dist/esm/integration/providers/aws-configuration-loader.service.js +0 -588
- package/dist/esm/integration/providers/aws-configuration-loader.service.js.map +0 -1
- package/dist/esm/integration/providers/configuration-factory.provider.js +0 -380
- package/dist/esm/integration/providers/configuration-factory.provider.js.map +0 -1
- package/dist/esm/integration/providers/index.js +0 -4
- package/dist/esm/integration/providers/index.js.map +0 -1
- package/dist/esm/integration/services/async-config-helper.service.js +0 -353
- package/dist/esm/integration/services/async-config-helper.service.js.map +0 -1
- package/dist/esm/integration/services/error-handler.service.js +0 -262
- package/dist/esm/integration/services/error-handler.service.js.map +0 -1
- package/dist/esm/integration/services/factory-registration.service.js +0 -509
- package/dist/esm/integration/services/factory-registration.service.js.map +0 -1
- package/dist/esm/integration/services/index.js +0 -10
- package/dist/esm/integration/services/index.js.map +0 -1
- package/dist/esm/integration/services/integration-state.service.js +0 -80
- package/dist/esm/integration/services/integration-state.service.js.map +0 -1
- package/dist/esm/integration/services/namespace-handler.service.js +0 -464
- package/dist/esm/integration/services/namespace-handler.service.js.map +0 -1
- package/dist/esm/integration/services/nestjs-config-integration.service.js +0 -313
- package/dist/esm/integration/services/nestjs-config-integration.service.js.map +0 -1
- package/dist/esm/integration/services/precedence-handler.service.js +0 -291
- package/dist/esm/integration/services/precedence-handler.service.js.map +0 -1
- package/dist/esm/integration/services/validation-integration.service.js +0 -585
- package/dist/esm/integration/services/validation-integration.service.js.map +0 -1
- package/dist/esm/integration/utils/config-integration.util.js +0 -240
- package/dist/esm/integration/utils/config-integration.util.js.map +0 -1
- package/dist/esm/integration/utils/index.js +0 -3
- package/dist/esm/integration/utils/index.js.map +0 -1
- package/dist/esm/interfaces/config-loader.interface.js +0 -2
- package/dist/esm/interfaces/config-loader.interface.js.map +0 -1
- package/dist/esm/interfaces/config-service.interface.js +0 -7
- package/dist/esm/interfaces/config-service.interface.js.map +0 -1
- package/dist/esm/interfaces/default-schema.interface.js +0 -59
- package/dist/esm/interfaces/default-schema.interface.js.map +0 -1
- package/dist/esm/interfaces/errors.interface.js +0 -69
- package/dist/esm/interfaces/errors.interface.js.map +0 -1
- package/dist/esm/interfaces/index.js +0 -9
- package/dist/esm/interfaces/index.js.map +0 -1
- package/dist/esm/interfaces/module-options.interface.js +0 -2
- package/dist/esm/interfaces/module-options.interface.js.map +0 -1
- package/dist/esm/loaders/environment.loader.js +0 -55
- package/dist/esm/loaders/environment.loader.js.map +0 -1
- package/dist/esm/loaders/secrets-manager.loader.js +0 -118
- package/dist/esm/loaders/secrets-manager.loader.js.map +0 -1
- package/dist/esm/loaders/ssm-parameter-store.loader.js +0 -142
- package/dist/esm/loaders/ssm-parameter-store.loader.js.map +0 -1
- package/dist/esm/services/config.service.js +0 -261
- package/dist/esm/services/config.service.js.map +0 -1
- package/dist/esm/utils/validation.util.js +0 -110
- package/dist/esm/utils/validation.util.js.map +0 -1
- package/dist/types/config.module.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/integration/index.d.ts.map +0 -1
- package/dist/types/integration/interfaces/configuration-factory.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/configuration-source.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/index.d.ts.map +0 -1
- package/dist/types/integration/interfaces/integration-options.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/integration-state.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/nestjs-config-compatibility.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/nestjs-config-integration.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/typed-configuration.interface.d.ts.map +0 -1
- package/dist/types/integration/interfaces/utility-types.interface.d.ts.map +0 -1
- package/dist/types/integration/nestjs-config-integration.module.d.ts.map +0 -1
- package/dist/types/integration/providers/aws-configuration-loader.service.d.ts.map +0 -1
- package/dist/types/integration/providers/configuration-factory.provider.d.ts.map +0 -1
- package/dist/types/integration/providers/index.d.ts.map +0 -1
- package/dist/types/integration/services/async-config-helper.service.d.ts.map +0 -1
- package/dist/types/integration/services/error-handler.service.d.ts.map +0 -1
- package/dist/types/integration/services/factory-registration.service.d.ts.map +0 -1
- package/dist/types/integration/services/index.d.ts.map +0 -1
- package/dist/types/integration/services/integration-state.service.d.ts.map +0 -1
- package/dist/types/integration/services/namespace-handler.service.d.ts.map +0 -1
- package/dist/types/integration/services/nestjs-config-integration.service.d.ts.map +0 -1
- package/dist/types/integration/services/precedence-handler.service.d.ts.map +0 -1
- package/dist/types/integration/services/validation-integration.service.d.ts.map +0 -1
- package/dist/types/integration/utils/config-integration.util.d.ts.map +0 -1
- package/dist/types/integration/utils/index.d.ts.map +0 -1
- package/dist/types/interfaces/config-loader.interface.d.ts +0 -22
- package/dist/types/interfaces/config-loader.interface.d.ts.map +0 -1
- package/dist/types/interfaces/config-service.interface.d.ts.map +0 -1
- package/dist/types/interfaces/default-schema.interface.d.ts.map +0 -1
- package/dist/types/interfaces/errors.interface.d.ts +0 -38
- package/dist/types/interfaces/errors.interface.d.ts.map +0 -1
- package/dist/types/interfaces/index.d.ts +0 -6
- package/dist/types/interfaces/index.d.ts.map +0 -1
- package/dist/types/interfaces/module-options.interface.d.ts.map +0 -1
- package/dist/types/loaders/environment.loader.d.ts +0 -26
- package/dist/types/loaders/environment.loader.d.ts.map +0 -1
- package/dist/types/loaders/secrets-manager.loader.d.ts +0 -52
- package/dist/types/loaders/secrets-manager.loader.d.ts.map +0 -1
- package/dist/types/loaders/ssm-parameter-store.loader.d.ts +0 -68
- package/dist/types/loaders/ssm-parameter-store.loader.d.ts.map +0 -1
- package/dist/types/services/config.service.d.ts +0 -94
- package/dist/types/services/config.service.d.ts.map +0 -1
- package/dist/types/utils/validation.util.d.ts.map +0 -1
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/index.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/configuration-factory.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/configuration-source.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/index.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/integration-options.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/integration-state.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/nestjs-config-compatibility.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/nestjs-config-integration.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/typed-configuration.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/interfaces/utility-types.interface.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/nestjs-config-integration.module.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/providers/aws-configuration-loader.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/providers/configuration-factory.provider.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/providers/index.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/async-config-helper.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/error-handler.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/factory-registration.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/index.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/integration-state.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/namespace-handler.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/nestjs-config-integration.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/precedence-handler.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/services/validation-integration.service.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/utils/config-integration.util.d.ts +0 -0
- /package/dist/types/{integration → nestjs-config-aws/src/integration}/utils/index.d.ts +0 -0
- /package/dist/types/{interfaces → nestjs-config-aws/src/interfaces}/config-service.interface.d.ts +0 -0
- /package/dist/types/{interfaces → nestjs-config-aws/src/interfaces}/module-options.interface.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,1183 +1,378 @@
|
|
|
1
|
-
# nestjs-config-aws
|
|
1
|
+
# @dyanet/nestjs-config-aws
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
NestJS adapter for AWS configuration management. A thin wrapper around [@dyanet/config-aws](../config-aws) that provides NestJS dependency injection and module patterns.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- 📦 **Zero-Configuration Setup**: Works out of the box with sensible defaults
|
|
13
|
-
- 🔄 **Configuration Merging**: Intelligent precedence handling across sources
|
|
14
|
-
- ⚡ **Performance Optimized**: Efficient loading with caching and pagination support
|
|
15
|
-
- 🤝 **@nestjs/config Integration**: Use AWS-sourced values through standard @nestjs/config patterns
|
|
16
|
-
- 🔀 **Flexible Precedence Rules**: aws-first, local-first, or merge strategies for configuration conflicts
|
|
17
|
-
|
|
18
|
-
## Table of Contents
|
|
19
|
-
|
|
20
|
-
- [Installation](#installation)
|
|
21
|
-
- [Quick Start](#quick-start)
|
|
22
|
-
- [Configuration](#configuration)
|
|
23
|
-
- [Environment Variables](#environment-variables)
|
|
24
|
-
- [Usage Examples](#usage-examples)
|
|
25
|
-
- [@nestjs/config Integration](#nestjsconfig-integration)
|
|
26
|
-
- [API Reference](#api-reference)
|
|
27
|
-
- [Troubleshooting](#troubleshooting)
|
|
28
|
-
- [Examples](#examples)
|
|
29
|
-
- [Contributing](#contributing)
|
|
30
|
-
- [License](#license)
|
|
7
|
+
- **NestJS Integration** - Full dependency injection support with `ConfigModule` and `ConfigService`
|
|
8
|
+
- **@nestjs/config Compatibility** - Seamless integration with the standard NestJS config module
|
|
9
|
+
- **Type Safety** - Full TypeScript support with Zod schema validation
|
|
10
|
+
- **AWS Services** - Load configuration from Secrets Manager, SSM Parameter Store, S3
|
|
11
|
+
- **Thin Adapter** - Minimal overhead, delegates to `@dyanet/config-aws` for all heavy lifting
|
|
31
12
|
|
|
32
13
|
## Installation
|
|
33
14
|
|
|
34
|
-
### Standalone Usage
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm install nestjs-config-aws
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### @nestjs/config Integration
|
|
41
|
-
|
|
42
|
-
For seamless integration with the standard @nestjs/config module:
|
|
43
|
-
|
|
44
15
|
```bash
|
|
45
|
-
npm install nestjs-config-aws
|
|
16
|
+
npm install @dyanet/nestjs-config-aws
|
|
46
17
|
```
|
|
47
18
|
|
|
48
19
|
### Peer Dependencies
|
|
49
20
|
|
|
50
|
-
Make sure you have the following peer dependencies installed:
|
|
51
|
-
|
|
52
21
|
```bash
|
|
53
|
-
npm install @nestjs/common @nestjs/core zod
|
|
22
|
+
npm install @nestjs/common @nestjs/core @nestjs/config zod
|
|
54
23
|
```
|
|
55
24
|
|
|
56
|
-
For
|
|
57
|
-
|
|
58
|
-
### AWS Dependencies
|
|
59
|
-
|
|
60
|
-
The module automatically includes the necessary AWS SDK dependencies:
|
|
61
|
-
- `@aws-sdk/client-secrets-manager`
|
|
62
|
-
- `@aws-sdk/client-ssm`
|
|
63
|
-
- `@aws-sdk/credential-providers`
|
|
64
|
-
|
|
65
|
-
## Quick Start
|
|
66
|
-
|
|
67
|
-
Choose your preferred integration approach:
|
|
25
|
+
For AWS services, install the SDK clients you need:
|
|
68
26
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
27
|
+
```bash
|
|
28
|
+
# For Secrets Manager
|
|
29
|
+
npm install @aws-sdk/client-secrets-manager
|
|
72
30
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
import { ConfigModule } from 'nestjs-config-aws';
|
|
31
|
+
# For SSM Parameter Store
|
|
32
|
+
npm install @aws-sdk/client-ssm
|
|
76
33
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
ConfigModule.forRoot(), // Uses default configuration
|
|
80
|
-
],
|
|
81
|
-
})
|
|
82
|
-
export class AppModule {}
|
|
34
|
+
# For S3
|
|
35
|
+
npm install @aws-sdk/client-s3
|
|
83
36
|
```
|
|
84
37
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Integrate with the standard @nestjs/config for maximum compatibility:
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
import { Module } from '@nestjs/common';
|
|
91
|
-
import { ConfigModule } from '@nestjs/config';
|
|
92
|
-
import { NestConfigAwsIntegrationModule } from 'nestjs-config-aws';
|
|
93
|
-
|
|
94
|
-
@Module({
|
|
95
|
-
imports: [
|
|
96
|
-
// Step 1: AWS Integration (must be first)
|
|
97
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
98
|
-
secretsManagerConfig: { enabled: true },
|
|
99
|
-
precedence: 'aws-first'
|
|
100
|
-
}),
|
|
101
|
-
|
|
102
|
-
// Step 2: Standard @nestjs/config (must be after)
|
|
103
|
-
ConfigModule.forRoot({ isGlobal: true })
|
|
104
|
-
],
|
|
105
|
-
})
|
|
106
|
-
export class AppModule {}
|
|
107
|
-
```
|
|
38
|
+
## Quick Start
|
|
108
39
|
|
|
109
|
-
###
|
|
40
|
+
### Basic Usage
|
|
110
41
|
|
|
111
42
|
```typescript
|
|
43
|
+
// app.module.ts
|
|
112
44
|
import { Module } from '@nestjs/common';
|
|
113
|
-
import { ConfigModule } from 'nestjs-config-aws';
|
|
45
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
114
46
|
import { z } from 'zod';
|
|
115
47
|
|
|
116
48
|
const configSchema = z.object({
|
|
117
|
-
PORT: z.coerce.number().default(3000),
|
|
118
49
|
DATABASE_URL: z.string(),
|
|
119
50
|
API_KEY: z.string(),
|
|
120
|
-
|
|
51
|
+
PORT: z.coerce.number().default(3000),
|
|
121
52
|
});
|
|
122
53
|
|
|
123
54
|
@Module({
|
|
124
55
|
imports: [
|
|
125
56
|
ConfigModule.forRoot({
|
|
126
57
|
schema: configSchema,
|
|
58
|
+
envPrefix: 'APP_',
|
|
59
|
+
secretsManagerConfig: {
|
|
60
|
+
enabled: true,
|
|
61
|
+
region: 'us-east-1',
|
|
62
|
+
},
|
|
127
63
|
}),
|
|
128
64
|
],
|
|
129
65
|
})
|
|
130
66
|
export class AppModule {}
|
|
131
67
|
```
|
|
132
68
|
|
|
133
|
-
###
|
|
134
|
-
|
|
135
|
-
Both approaches use the same service patterns:
|
|
69
|
+
### Using ConfigService
|
|
136
70
|
|
|
137
71
|
```typescript
|
|
72
|
+
// app.service.ts
|
|
138
73
|
import { Injectable } from '@nestjs/common';
|
|
139
|
-
|
|
140
|
-
// For integration: import { ConfigService } from '@nestjs/config';
|
|
141
|
-
import { ConfigService } from '@nestjs/config';
|
|
74
|
+
import { ConfigService } from '@dyanet/nestjs-config-aws';
|
|
142
75
|
|
|
143
76
|
@Injectable()
|
|
144
77
|
export class AppService {
|
|
145
|
-
constructor(private
|
|
78
|
+
constructor(private readonly config: ConfigService) {}
|
|
146
79
|
|
|
147
|
-
getPort(): number {
|
|
148
|
-
return this.configService.get('PORT'); // Values can come from AWS
|
|
149
|
-
}
|
|
150
|
-
|
|
151
80
|
getDatabaseUrl(): string {
|
|
152
|
-
|
|
153
|
-
return this.configService.get('DATABASE_URL');
|
|
81
|
+
return this.config.get('DATABASE_URL');
|
|
154
82
|
}
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## Configuration
|
|
159
|
-
|
|
160
|
-
### Module Options
|
|
161
|
-
|
|
162
|
-
The `ConfigModule.forRoot()` method accepts the following options:
|
|
163
83
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
secretsManagerConfig?: SecretsManagerConfig;
|
|
168
|
-
ssmConfig?: SSMConfig;
|
|
169
|
-
envPrefix?: string;
|
|
170
|
-
ignoreValidationErrors?: boolean;
|
|
171
|
-
appEnvVariable?: string;
|
|
172
|
-
loadSync?: boolean;
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### AWS Secrets Manager Configuration
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
interface SecretsManagerConfig {
|
|
180
|
-
region?: string;
|
|
181
|
-
paths?: {
|
|
182
|
-
development?: string;
|
|
183
|
-
test?: string;
|
|
184
|
-
production?: string;
|
|
185
|
-
};
|
|
186
|
-
enabled?: boolean;
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### AWS SSM Parameter Store Configuration
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
interface SSMConfig {
|
|
194
|
-
region?: string;
|
|
195
|
-
paths?: {
|
|
196
|
-
development?: string;
|
|
197
|
-
test?: string;
|
|
198
|
-
production?: string;
|
|
199
|
-
};
|
|
200
|
-
enabled?: boolean;
|
|
201
|
-
decrypt?: boolean;
|
|
84
|
+
getPort(): number {
|
|
85
|
+
return this.config.get('PORT');
|
|
86
|
+
}
|
|
202
87
|
}
|
|
203
88
|
```
|
|
204
89
|
|
|
205
|
-
##
|
|
206
|
-
|
|
207
|
-
### Core Environment Variables
|
|
208
|
-
|
|
209
|
-
| Variable | Description | Default | Required |
|
|
210
|
-
|----------|-------------|---------|----------|
|
|
211
|
-
| `APP_ENV` | Application environment | `local` | No |
|
|
212
|
-
| `NODE_ENV` | Node.js environment | - | No |
|
|
213
|
-
| `AWS_REGION` | AWS region for services | Auto-detected | No |
|
|
214
|
-
| `AWS_PROFILE` | AWS profile for local development | - | No |
|
|
215
|
-
|
|
216
|
-
### APP_ENV Behavior
|
|
217
|
-
|
|
218
|
-
The `APP_ENV` variable controls configuration loading behavior:
|
|
219
|
-
|
|
220
|
-
- **`local`**: Only loads environment variables. AWS services are used only if valid AWS credentials are found.
|
|
221
|
-
- **`development`**: Loads from environment variables, AWS Secrets Manager, and SSM Parameter Store using development paths.
|
|
222
|
-
- **`test`**: Loads from environment variables, AWS Secrets Manager, and SSM Parameter Store using test paths.
|
|
223
|
-
- **`production`**: Loads from environment variables, AWS Secrets Manager, and SSM Parameter Store using production paths.
|
|
224
|
-
|
|
225
|
-
### Environment Variable Precedence
|
|
226
|
-
|
|
227
|
-
Configuration values are loaded in the following order (later sources override earlier ones):
|
|
228
|
-
|
|
229
|
-
1. **Environment Variables** (`process.env`)
|
|
230
|
-
2. **AWS Secrets Manager** (if enabled and not in local mode)
|
|
231
|
-
3. **AWS SSM Parameter Store** (if enabled and not in local mode)
|
|
232
|
-
4. **Local .env file** (in local mode only, overrides AWS sources)
|
|
233
|
-
|
|
234
|
-
### AWS Path Construction
|
|
235
|
-
|
|
236
|
-
By default, the module constructs AWS resource paths using the following patterns:
|
|
237
|
-
|
|
238
|
-
**Secrets Manager:**
|
|
239
|
-
- Development: `/myapp/development/secrets`
|
|
240
|
-
- Test: `/myapp/test/secrets`
|
|
241
|
-
- Production: `/myapp/production/secrets`
|
|
242
|
-
|
|
243
|
-
**SSM Parameter Store:**
|
|
244
|
-
- Development: `/myapp/development/`
|
|
245
|
-
- Test: `/myapp/test/`
|
|
246
|
-
- Production: `/myapp/production/`
|
|
247
|
-
|
|
248
|
-
## Usage Examples
|
|
249
|
-
|
|
250
|
-
### Basic Configuration
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
// app.module.ts
|
|
254
|
-
import { Module } from '@nestjs/common';
|
|
255
|
-
import { ConfigModule } from 'nestjs-config-aws';
|
|
256
|
-
|
|
257
|
-
@Module({
|
|
258
|
-
imports: [ConfigModule.forRoot()],
|
|
259
|
-
})
|
|
260
|
-
export class AppModule {}
|
|
261
|
-
|
|
262
|
-
// app.service.ts
|
|
263
|
-
import { Injectable } from '@nestjs/common';
|
|
264
|
-
import { ConfigService } from 'nestjs-config-aws';
|
|
265
|
-
|
|
266
|
-
@Injectable()
|
|
267
|
-
export class AppService {
|
|
268
|
-
constructor(private configService: ConfigService) {}
|
|
90
|
+
## ConfigModule
|
|
269
91
|
|
|
270
|
-
|
|
271
|
-
return this.configService.get('DATABASE_URL');
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
```
|
|
92
|
+
### forRoot()
|
|
275
93
|
|
|
276
|
-
|
|
94
|
+
Synchronous module registration with static options:
|
|
277
95
|
|
|
278
96
|
```typescript
|
|
97
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
279
98
|
import { z } from 'zod';
|
|
280
99
|
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
PORT: z.coerce.number().
|
|
284
|
-
HOST: z.string().default('localhost'),
|
|
285
|
-
|
|
286
|
-
// Database configuration
|
|
287
|
-
DATABASE_URL: z.string().url(),
|
|
288
|
-
DATABASE_POOL_SIZE: z.coerce.number().min(1).default(10),
|
|
289
|
-
|
|
290
|
-
// External services
|
|
291
|
-
REDIS_URL: z.string().url().optional(),
|
|
292
|
-
API_KEY: z.string().min(1),
|
|
293
|
-
|
|
294
|
-
// Feature flags
|
|
295
|
-
ENABLE_LOGGING: z.coerce.boolean().default(true),
|
|
296
|
-
DEBUG_MODE: z.coerce.boolean().default(false),
|
|
100
|
+
const schema = z.object({
|
|
101
|
+
DATABASE_URL: z.string(),
|
|
102
|
+
PORT: z.coerce.number().default(3000),
|
|
297
103
|
});
|
|
298
104
|
|
|
299
|
-
type AppConfig = z.infer<typeof appConfigSchema>;
|
|
300
|
-
|
|
301
|
-
@Module({
|
|
302
|
-
imports: [
|
|
303
|
-
ConfigModule.forRoot({
|
|
304
|
-
schema: appConfigSchema,
|
|
305
|
-
}),
|
|
306
|
-
],
|
|
307
|
-
})
|
|
308
|
-
export class AppModule {}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Advanced AWS Configuration
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
105
|
@Module({
|
|
315
106
|
imports: [
|
|
316
107
|
ConfigModule.forRoot({
|
|
317
|
-
schema
|
|
108
|
+
schema,
|
|
109
|
+
envPrefix: 'APP_',
|
|
318
110
|
secretsManagerConfig: {
|
|
111
|
+
enabled: true,
|
|
319
112
|
region: 'us-east-1',
|
|
320
113
|
paths: {
|
|
321
|
-
development: '
|
|
322
|
-
|
|
323
|
-
production: '/myapp/prod/secrets',
|
|
114
|
+
development: 'dev/',
|
|
115
|
+
production: 'prod/',
|
|
324
116
|
},
|
|
325
|
-
enabled: true,
|
|
326
117
|
},
|
|
327
118
|
ssmConfig: {
|
|
119
|
+
enabled: true,
|
|
328
120
|
region: 'us-east-1',
|
|
121
|
+
decrypt: true,
|
|
329
122
|
paths: {
|
|
330
|
-
development: '/
|
|
331
|
-
|
|
332
|
-
production: '/myapp/prod/config/',
|
|
123
|
+
development: '/app/dev',
|
|
124
|
+
production: '/app/prod',
|
|
333
125
|
},
|
|
334
|
-
enabled: true,
|
|
335
|
-
decrypt: true,
|
|
336
126
|
},
|
|
337
|
-
envPrefix: 'MYAPP_',
|
|
338
127
|
}),
|
|
339
128
|
],
|
|
340
129
|
})
|
|
341
130
|
export class AppModule {}
|
|
342
131
|
```
|
|
343
132
|
|
|
344
|
-
###
|
|
133
|
+
### forRootAsync()
|
|
134
|
+
|
|
135
|
+
Asynchronous module registration with factory function:
|
|
345
136
|
|
|
346
137
|
```typescript
|
|
138
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
139
|
+
import { SomeService } from './some.service';
|
|
140
|
+
|
|
347
141
|
@Module({
|
|
348
142
|
imports: [
|
|
349
143
|
ConfigModule.forRootAsync({
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
secretsManagerConfig: {
|
|
356
|
-
enabled: process.env.NODE_ENV !== 'test',
|
|
357
|
-
},
|
|
358
|
-
};
|
|
359
|
-
},
|
|
360
|
-
}),
|
|
361
|
-
],
|
|
362
|
-
})
|
|
363
|
-
export class AppModule {}
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### Environment-Specific Configuration
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
// Different configurations based on APP_ENV
|
|
370
|
-
const getConfigForEnvironment = () => {
|
|
371
|
-
const baseConfig = {
|
|
372
|
-
schema: appConfigSchema,
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
switch (process.env.APP_ENV) {
|
|
376
|
-
case 'local':
|
|
377
|
-
return {
|
|
378
|
-
...baseConfig,
|
|
379
|
-
secretsManagerConfig: { enabled: false },
|
|
380
|
-
ssmConfig: { enabled: false },
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
case 'development':
|
|
384
|
-
return {
|
|
385
|
-
...baseConfig,
|
|
386
|
-
secretsManagerConfig: {
|
|
387
|
-
enabled: true,
|
|
388
|
-
paths: { development: '/myapp/dev/secrets' },
|
|
389
|
-
},
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
case 'production':
|
|
393
|
-
return {
|
|
394
|
-
...baseConfig,
|
|
144
|
+
imports: [SomeModule],
|
|
145
|
+
inject: [SomeService],
|
|
146
|
+
useFactory: async (someService: SomeService) => ({
|
|
147
|
+
schema: someService.getConfigSchema(),
|
|
148
|
+
envPrefix: 'APP_',
|
|
395
149
|
secretsManagerConfig: {
|
|
396
150
|
enabled: true,
|
|
397
|
-
|
|
151
|
+
region: await someService.getAwsRegion(),
|
|
398
152
|
},
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
},
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
default:
|
|
406
|
-
return baseConfig;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
@Module({
|
|
411
|
-
imports: [ConfigModule.forRoot(getConfigForEnvironment())],
|
|
153
|
+
}),
|
|
154
|
+
}),
|
|
155
|
+
],
|
|
412
156
|
})
|
|
413
157
|
export class AppModule {}
|
|
414
158
|
```
|
|
415
159
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
nestjs-config-aws provides seamless integration with the standard `@nestjs/config` module, allowing you to use AWS-sourced configuration values through the familiar `@nestjs/config` patterns. This integration maintains backward compatibility while adding AWS capabilities.
|
|
419
|
-
|
|
420
|
-
### Installation for Integration
|
|
160
|
+
### Module Options
|
|
421
161
|
|
|
422
|
-
|
|
162
|
+
| Option | Type | Default | Description |
|
|
163
|
+
|--------|------|---------|-------------|
|
|
164
|
+
| `schema` | `ZodType<T>` | Default schema | Zod schema for validation |
|
|
165
|
+
| `envPrefix` | `string` | `undefined` | Prefix for environment variables |
|
|
166
|
+
| `secretsManagerConfig` | `SecretsManagerConfig` | `undefined` | Secrets Manager configuration |
|
|
167
|
+
| `ssmConfig` | `SSMConfig` | `undefined` | SSM Parameter Store configuration |
|
|
168
|
+
| `ignoreValidationErrors` | `boolean` | `false` | Continue with partial config on validation errors |
|
|
169
|
+
| `loadSync` | `boolean` | `false` | Load configuration synchronously |
|
|
423
170
|
|
|
424
|
-
|
|
425
|
-
npm install nestjs-config-aws @nestjs/config
|
|
426
|
-
```
|
|
171
|
+
#### SecretsManagerConfig
|
|
427
172
|
|
|
428
|
-
|
|
173
|
+
| Option | Type | Default | Description |
|
|
174
|
+
|--------|------|---------|-------------|
|
|
175
|
+
| `enabled` | `boolean` | `true` | Enable Secrets Manager integration |
|
|
176
|
+
| `region` | `string` | `undefined` | AWS region |
|
|
177
|
+
| `paths` | `object` | `undefined` | Environment-specific path prefixes |
|
|
429
178
|
|
|
430
|
-
|
|
431
|
-
import { Module } from '@nestjs/common';
|
|
432
|
-
import { ConfigModule } from '@nestjs/config';
|
|
433
|
-
import { NestConfigAwsIntegrationModule } from 'nestjs-config-aws';
|
|
179
|
+
#### SSMConfig
|
|
434
180
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
paths: {
|
|
442
|
-
production: '/myapp/prod/secrets'
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
precedence: 'aws-first'
|
|
446
|
-
}),
|
|
447
|
-
|
|
448
|
-
// Standard @nestjs/config setup
|
|
449
|
-
ConfigModule.forRoot({
|
|
450
|
-
isGlobal: true,
|
|
451
|
-
cache: true
|
|
452
|
-
})
|
|
453
|
-
]
|
|
454
|
-
})
|
|
455
|
-
export class AppModule {}
|
|
456
|
-
```
|
|
181
|
+
| Option | Type | Default | Description |
|
|
182
|
+
|--------|------|---------|-------------|
|
|
183
|
+
| `enabled` | `boolean` | `true` | Enable SSM Parameter Store integration |
|
|
184
|
+
| `region` | `string` | `undefined` | AWS region |
|
|
185
|
+
| `decrypt` | `boolean` | `true` | Decrypt SecureString parameters |
|
|
186
|
+
| `paths` | `object` | `undefined` | Environment-specific path prefixes |
|
|
457
187
|
|
|
458
|
-
|
|
188
|
+
## ConfigService
|
|
459
189
|
|
|
460
|
-
|
|
190
|
+
The `ConfigService` is automatically registered as a global provider:
|
|
461
191
|
|
|
462
192
|
```typescript
|
|
463
193
|
import { Injectable } from '@nestjs/common';
|
|
464
|
-
import { ConfigService } from '@nestjs
|
|
194
|
+
import { ConfigService } from '@dyanet/nestjs-config-aws';
|
|
465
195
|
|
|
466
196
|
@Injectable()
|
|
467
|
-
export class
|
|
468
|
-
constructor(private
|
|
197
|
+
export class MyService {
|
|
198
|
+
constructor(private readonly config: ConfigService) {}
|
|
469
199
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return this.
|
|
200
|
+
// Get a specific value
|
|
201
|
+
getValue(): string {
|
|
202
|
+
return this.config.get('MY_KEY');
|
|
473
203
|
}
|
|
474
204
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return this.
|
|
205
|
+
// Get all configuration
|
|
206
|
+
getAllConfig() {
|
|
207
|
+
return this.config.getAll();
|
|
478
208
|
}
|
|
479
|
-
}
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### Integration Configuration Options
|
|
483
209
|
|
|
484
|
-
|
|
210
|
+
// Check if initialized
|
|
211
|
+
isReady(): boolean {
|
|
212
|
+
return this.config.isInitialized();
|
|
213
|
+
}
|
|
485
214
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
ssmConfig?: SSMConfig;
|
|
491
|
-
|
|
492
|
-
// Integration Settings
|
|
493
|
-
precedence?: 'aws-first' | 'local-first' | 'merge';
|
|
494
|
-
namespaces?: string[];
|
|
495
|
-
enableLogging?: boolean;
|
|
496
|
-
|
|
497
|
-
// @nestjs/config compatibility
|
|
498
|
-
registerGlobally?: boolean;
|
|
499
|
-
factoryOptions?: {
|
|
500
|
-
cache?: boolean;
|
|
501
|
-
expandVariables?: boolean;
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
// Error handling
|
|
505
|
-
failOnAwsError?: boolean;
|
|
506
|
-
fallbackToLocal?: boolean;
|
|
215
|
+
// Get current environment
|
|
216
|
+
getEnvironment(): string {
|
|
217
|
+
return this.config.getAppEnv();
|
|
218
|
+
}
|
|
507
219
|
}
|
|
508
220
|
```
|
|
509
221
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
The integration supports three precedence strategies:
|
|
513
|
-
|
|
514
|
-
#### 1. AWS-First (Default)
|
|
515
|
-
AWS values override local values when both exist:
|
|
516
|
-
```typescript
|
|
517
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
518
|
-
precedence: 'aws-first' // AWS values take priority
|
|
519
|
-
})
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
#### 2. Local-First
|
|
523
|
-
Local values override AWS values when both exist:
|
|
524
|
-
```typescript
|
|
525
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
526
|
-
precedence: 'local-first' // Local .env values take priority
|
|
527
|
-
})
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
#### 3. Merge
|
|
531
|
-
Combines values from all sources intelligently:
|
|
532
|
-
```typescript
|
|
533
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
534
|
-
precedence: 'merge' // Merge all sources with smart conflict resolution
|
|
535
|
-
})
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
### Async Configuration Integration
|
|
222
|
+
## @nestjs/config Integration
|
|
539
223
|
|
|
540
|
-
|
|
224
|
+
Use `NestConfigAwsIntegrationModule` for seamless integration with `@nestjs/config`:
|
|
541
225
|
|
|
542
226
|
```typescript
|
|
543
227
|
import { Module } from '@nestjs/common';
|
|
544
|
-
import { ConfigModule
|
|
545
|
-
import { NestConfigAwsIntegrationModule } from 'nestjs-config-aws';
|
|
546
|
-
|
|
547
|
-
@Module({
|
|
548
|
-
imports: [
|
|
549
|
-
NestConfigAwsIntegrationModule.forRootAsync({
|
|
550
|
-
useFactory: async () => ({
|
|
551
|
-
secretsManagerConfig: {
|
|
552
|
-
enabled: process.env.NODE_ENV === 'production',
|
|
553
|
-
region: process.env.AWS_REGION,
|
|
554
|
-
paths: {
|
|
555
|
-
production: `/myapp/${process.env.DEPLOYMENT_STAGE}/secrets`
|
|
556
|
-
}
|
|
557
|
-
},
|
|
558
|
-
precedence: 'aws-first',
|
|
559
|
-
failOnAwsError: false
|
|
560
|
-
})
|
|
561
|
-
}),
|
|
562
|
-
|
|
563
|
-
ConfigModule.forRootAsync({
|
|
564
|
-
useFactory: async (configService: ConfigService) => ({
|
|
565
|
-
isGlobal: true,
|
|
566
|
-
validate: (config) => {
|
|
567
|
-
// Validate AWS-sourced configuration
|
|
568
|
-
if (!config.DATABASE_URL) {
|
|
569
|
-
throw new Error('DATABASE_URL is required');
|
|
570
|
-
}
|
|
571
|
-
return config;
|
|
572
|
-
}
|
|
573
|
-
}),
|
|
574
|
-
inject: [ConfigService]
|
|
575
|
-
})
|
|
576
|
-
]
|
|
577
|
-
})
|
|
578
|
-
export class AppModule {}
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
### Namespaced Configuration
|
|
582
|
-
|
|
583
|
-
The integration supports @nestjs/config's `registerAs` pattern for namespaced configuration:
|
|
228
|
+
import { ConfigModule as NestConfigModule } from '@nestjs/config';
|
|
229
|
+
import { NestConfigAwsIntegrationModule } from '@dyanet/nestjs-config-aws';
|
|
584
230
|
|
|
585
|
-
```typescript
|
|
586
|
-
// config/database.config.ts
|
|
587
|
-
import { registerAs } from '@nestjs/config';
|
|
588
|
-
|
|
589
|
-
export default registerAs('database', () => ({
|
|
590
|
-
host: process.env.DATABASE_HOST, // Can come from AWS
|
|
591
|
-
port: parseInt(process.env.DATABASE_PORT, 10),
|
|
592
|
-
username: process.env.DATABASE_USERNAME, // From AWS Secrets Manager
|
|
593
|
-
password: process.env.DATABASE_PASSWORD, // From AWS Secrets Manager
|
|
594
|
-
}));
|
|
595
|
-
|
|
596
|
-
// app.module.ts
|
|
597
231
|
@Module({
|
|
598
232
|
imports: [
|
|
233
|
+
NestConfigModule.forRoot(),
|
|
599
234
|
NestConfigAwsIntegrationModule.forRoot({
|
|
600
|
-
|
|
601
|
-
secretsManagerConfig: {
|
|
602
|
-
enabled: true,
|
|
603
|
-
paths: {
|
|
604
|
-
production: '/myapp/prod/database'
|
|
605
|
-
}
|
|
606
|
-
}
|
|
235
|
+
registerGlobally: true,
|
|
607
236
|
}),
|
|
608
|
-
|
|
609
|
-
ConfigModule.forRoot({
|
|
610
|
-
load: [databaseConfig],
|
|
611
|
-
isGlobal: true
|
|
612
|
-
})
|
|
613
|
-
]
|
|
237
|
+
],
|
|
614
238
|
})
|
|
615
239
|
export class AppModule {}
|
|
616
|
-
|
|
617
|
-
// database.service.ts
|
|
618
|
-
import { Injectable } from '@nestjs/common';
|
|
619
|
-
import { ConfigService } from '@nestjs/config';
|
|
620
|
-
|
|
621
|
-
@Injectable()
|
|
622
|
-
export class DatabaseService {
|
|
623
|
-
constructor(private configService: ConfigService) {}
|
|
624
|
-
|
|
625
|
-
getConnectionConfig() {
|
|
626
|
-
// Access namespaced configuration
|
|
627
|
-
return this.configService.get('database');
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
240
|
```
|
|
631
241
|
|
|
632
|
-
###
|
|
633
|
-
|
|
634
|
-
The integration works seamlessly with @nestjs/config validation:
|
|
635
|
-
|
|
636
|
-
#### Using Joi Validation
|
|
242
|
+
### Async Integration
|
|
637
243
|
|
|
638
244
|
```typescript
|
|
639
|
-
import
|
|
245
|
+
import { NestConfigAwsIntegrationModule } from '@dyanet/nestjs-config-aws';
|
|
640
246
|
|
|
641
247
|
@Module({
|
|
642
248
|
imports: [
|
|
643
|
-
NestConfigAwsIntegrationModule.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
NODE_ENV: Joi.string()
|
|
650
|
-
.valid('development', 'production', 'test')
|
|
651
|
-
.default('development'),
|
|
652
|
-
PORT: Joi.number().default(3000),
|
|
653
|
-
DATABASE_URL: Joi.string().required(), // Can come from AWS
|
|
654
|
-
API_KEY: Joi.string().required(), // Can come from AWS
|
|
249
|
+
NestConfigAwsIntegrationModule.forRootAsync({
|
|
250
|
+
imports: [SomeModule],
|
|
251
|
+
inject: [SomeService],
|
|
252
|
+
useFactory: async (someService: SomeService) => ({
|
|
253
|
+
registerGlobally: true,
|
|
254
|
+
// Additional options from someService
|
|
655
255
|
}),
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
abortEarly: false,
|
|
659
|
-
}
|
|
660
|
-
})
|
|
661
|
-
]
|
|
256
|
+
}),
|
|
257
|
+
],
|
|
662
258
|
})
|
|
663
259
|
export class AppModule {}
|
|
664
260
|
```
|
|
665
261
|
|
|
666
|
-
|
|
262
|
+
## Migration from Monolithic Package
|
|
667
263
|
|
|
668
|
-
|
|
669
|
-
import { IsString, IsNumber, IsUrl } from 'class-validator';
|
|
670
|
-
import { Transform } from 'class-transformer';
|
|
264
|
+
If you're upgrading from an older version of `@dyanet/nestjs-config-aws` that included all functionality in one package:
|
|
671
265
|
|
|
672
|
-
|
|
673
|
-
@IsString()
|
|
674
|
-
NODE_ENV: string;
|
|
266
|
+
### What Changed
|
|
675
267
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
268
|
+
1. **Core functionality moved to `@dyanet/config-aws`** - All loaders, ConfigManager, and utilities are now in the core package
|
|
269
|
+
2. **This package is now a thin adapter** - It re-exports everything from `@dyanet/config-aws` and adds NestJS-specific integration
|
|
270
|
+
3. **Same API surface** - The public API remains the same for backward compatibility
|
|
679
271
|
|
|
680
|
-
|
|
681
|
-
DATABASE_URL: string; // Can come from AWS
|
|
272
|
+
### Migration Steps
|
|
682
273
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
@Module({
|
|
688
|
-
imports: [
|
|
689
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
690
|
-
secretsManagerConfig: { enabled: true }
|
|
691
|
-
}),
|
|
692
|
-
|
|
693
|
-
ConfigModule.forRoot({
|
|
694
|
-
validate: (config: Record<string, unknown>) => {
|
|
695
|
-
const validatedConfig = plainToClass(EnvironmentVariables, config, {
|
|
696
|
-
enableImplicitConversion: true,
|
|
697
|
-
});
|
|
698
|
-
const errors = validateSync(validatedConfig, {
|
|
699
|
-
skipMissingProperties: false,
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
if (errors.length > 0) {
|
|
703
|
-
throw new Error(errors.toString());
|
|
704
|
-
}
|
|
705
|
-
return validatedConfig;
|
|
706
|
-
},
|
|
707
|
-
})
|
|
708
|
-
]
|
|
709
|
-
})
|
|
710
|
-
export class AppModule {}
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
### Error Handling and Graceful Degradation
|
|
714
|
-
|
|
715
|
-
The integration provides robust error handling:
|
|
274
|
+
1. **No code changes required** - The package re-exports all types and classes from `@dyanet/config-aws`
|
|
275
|
+
2. **Optional: Use core package directly** - For non-NestJS code, you can import from `@dyanet/config-aws` directly
|
|
716
276
|
|
|
717
277
|
```typescript
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
enabled: true,
|
|
721
|
-
paths: { production: '/myapp/prod/secrets' }
|
|
722
|
-
},
|
|
723
|
-
|
|
724
|
-
// Error handling options
|
|
725
|
-
failOnAwsError: false, // Don't fail if AWS is unavailable
|
|
726
|
-
fallbackToLocal: true, // Use local config if AWS fails
|
|
727
|
-
enableLogging: true, // Enable detailed logging
|
|
728
|
-
|
|
729
|
-
// Graceful degradation
|
|
730
|
-
precedence: 'local-first' // Prefer local values as fallback
|
|
731
|
-
})
|
|
732
|
-
```
|
|
278
|
+
// Before (still works)
|
|
279
|
+
import { EnvironmentLoader, ConfigManager } from '@dyanet/nestjs-config-aws';
|
|
733
280
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
#### From @nestjs/config Only
|
|
737
|
-
|
|
738
|
-
If you're currently using only `@nestjs/config`:
|
|
739
|
-
|
|
740
|
-
1. **Install nestjs-config-aws**:
|
|
741
|
-
```bash
|
|
742
|
-
npm install nestjs-config-aws
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
2. **Add integration module** before your existing ConfigModule:
|
|
746
|
-
```typescript
|
|
747
|
-
@Module({
|
|
748
|
-
imports: [
|
|
749
|
-
// Add this before ConfigModule
|
|
750
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
751
|
-
secretsManagerConfig: { enabled: true }
|
|
752
|
-
}),
|
|
753
|
-
|
|
754
|
-
// Your existing ConfigModule setup
|
|
755
|
-
ConfigModule.forRoot({
|
|
756
|
-
isGlobal: true
|
|
757
|
-
})
|
|
758
|
-
]
|
|
759
|
-
})
|
|
760
|
-
```
|
|
761
|
-
|
|
762
|
-
3. **No code changes needed** - your existing ConfigService usage continues to work
|
|
763
|
-
|
|
764
|
-
4. **Configure AWS resources** - add secrets to AWS Secrets Manager or SSM Parameter Store
|
|
765
|
-
|
|
766
|
-
#### From nestjs-config-aws Only
|
|
767
|
-
|
|
768
|
-
If you're currently using only `nestjs-config-aws`:
|
|
769
|
-
|
|
770
|
-
1. **Install @nestjs/config**:
|
|
771
|
-
```bash
|
|
772
|
-
npm install @nestjs/config
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
2. **Replace ConfigModule import**:
|
|
776
|
-
```typescript
|
|
777
|
-
// Before
|
|
778
|
-
import { ConfigModule } from 'nestjs-config-aws';
|
|
779
|
-
|
|
780
|
-
// After
|
|
781
|
-
import { ConfigModule } from '@nestjs/config';
|
|
782
|
-
import { NestConfigAwsIntegrationModule } from 'nestjs-config-aws';
|
|
783
|
-
```
|
|
784
|
-
|
|
785
|
-
3. **Update module imports**:
|
|
786
|
-
```typescript
|
|
787
|
-
@Module({
|
|
788
|
-
imports: [
|
|
789
|
-
// Add integration module
|
|
790
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
791
|
-
// Your existing nestjs-config-aws options
|
|
792
|
-
}),
|
|
793
|
-
|
|
794
|
-
// Add standard ConfigModule
|
|
795
|
-
ConfigModule.forRoot({
|
|
796
|
-
isGlobal: true
|
|
797
|
-
})
|
|
798
|
-
]
|
|
799
|
-
})
|
|
800
|
-
```
|
|
801
|
-
|
|
802
|
-
4. **Update service injection**:
|
|
803
|
-
```typescript
|
|
804
|
-
// Before
|
|
805
|
-
import { ConfigService } from 'nestjs-config-aws';
|
|
806
|
-
|
|
807
|
-
// After
|
|
808
|
-
import { ConfigService } from '@nestjs/config';
|
|
809
|
-
```
|
|
810
|
-
|
|
811
|
-
### Integration Troubleshooting
|
|
812
|
-
|
|
813
|
-
#### Common Integration Issues
|
|
814
|
-
|
|
815
|
-
**1. Configuration Not Loading from AWS**
|
|
816
|
-
|
|
817
|
-
Check that the integration module is imported before ConfigModule:
|
|
818
|
-
```typescript
|
|
819
|
-
@Module({
|
|
820
|
-
imports: [
|
|
821
|
-
NestConfigAwsIntegrationModule.forRoot({}), // Must be first
|
|
822
|
-
ConfigModule.forRoot({}) // Then ConfigModule
|
|
823
|
-
]
|
|
824
|
-
})
|
|
281
|
+
// After (optional, for non-NestJS code)
|
|
282
|
+
import { EnvironmentLoader, ConfigManager } from '@dyanet/config-aws';
|
|
825
283
|
```
|
|
826
284
|
|
|
827
|
-
|
|
285
|
+
## Advanced Usage
|
|
828
286
|
|
|
829
|
-
|
|
830
|
-
```typescript
|
|
831
|
-
NestConfigAwsIntegrationModule.forRootAsync({
|
|
832
|
-
useFactory: async () => {
|
|
833
|
-
// Async setup ensures proper initialization order
|
|
834
|
-
return { secretsManagerConfig: { enabled: true } };
|
|
835
|
-
}
|
|
836
|
-
})
|
|
837
|
-
```
|
|
287
|
+
### Custom Loaders
|
|
838
288
|
|
|
839
|
-
|
|
289
|
+
Use loaders from `@dyanet/config-aws` directly:
|
|
840
290
|
|
|
841
|
-
Verify precedence configuration:
|
|
842
291
|
```typescript
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
292
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
293
|
+
import {
|
|
294
|
+
EnvironmentLoader,
|
|
295
|
+
EnvFileLoader,
|
|
296
|
+
S3Loader,
|
|
297
|
+
SecretsManagerLoader,
|
|
298
|
+
SSMParameterStoreLoader,
|
|
299
|
+
ConfigManager
|
|
300
|
+
} from '@dyanet/nestjs-config-aws';
|
|
301
|
+
|
|
302
|
+
// Create custom ConfigManager
|
|
303
|
+
const configManager = new ConfigManager({
|
|
304
|
+
loaders: [
|
|
305
|
+
new EnvironmentLoader({ prefix: 'APP_' }),
|
|
306
|
+
new EnvFileLoader({ paths: ['.env', '.env.local'] }),
|
|
307
|
+
new S3Loader({ bucket: 'my-bucket', key: 'config.json' }),
|
|
308
|
+
new SecretsManagerLoader({ secretName: '/my-app/secrets' }),
|
|
309
|
+
new SSMParameterStoreLoader({ parameterPath: '/my-app/params' }),
|
|
310
|
+
],
|
|
311
|
+
precedence: 'aws-first',
|
|
312
|
+
verbose: true,
|
|
313
|
+
});
|
|
847
314
|
```
|
|
848
315
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
Check that AWS values match validation schema:
|
|
852
|
-
```typescript
|
|
853
|
-
// Enable detailed logging to see loaded values
|
|
854
|
-
NestConfigAwsIntegrationModule.forRoot({
|
|
855
|
-
enableLogging: true,
|
|
856
|
-
failOnAwsError: false // Don't fail on AWS errors during debugging
|
|
857
|
-
})
|
|
858
|
-
```
|
|
316
|
+
### Accessing ConfigManager
|
|
859
317
|
|
|
860
|
-
|
|
318
|
+
Get the underlying `ConfigManager` for advanced use cases:
|
|
861
319
|
|
|
862
|
-
Ensure namespace configuration matches registerAs usage:
|
|
863
320
|
```typescript
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
namespaces: ['database', 'redis'] // Must match registerAs names
|
|
867
|
-
})
|
|
868
|
-
|
|
869
|
-
// In config files
|
|
870
|
-
export default registerAs('database', () => ({ /* config */ }));
|
|
871
|
-
```
|
|
872
|
-
|
|
873
|
-
#### Debug Integration Issues
|
|
874
|
-
|
|
875
|
-
Enable debug logging:
|
|
876
|
-
```bash
|
|
877
|
-
DEBUG=nestjs-config-aws:integration* npm start
|
|
878
|
-
```
|
|
879
|
-
|
|
880
|
-
This provides detailed logs about:
|
|
881
|
-
- AWS configuration loading
|
|
882
|
-
- Factory registration with @nestjs/config
|
|
883
|
-
- Precedence rule application
|
|
884
|
-
- Namespace handling
|
|
885
|
-
- Error scenarios
|
|
886
|
-
|
|
887
|
-
## API Reference
|
|
888
|
-
|
|
889
|
-
### ConfigModule
|
|
890
|
-
|
|
891
|
-
#### `ConfigModule.forRoot(options?: NestConfigAwsModuleOptions)`
|
|
892
|
-
|
|
893
|
-
Configures the module with the provided options.
|
|
894
|
-
|
|
895
|
-
**Parameters:**
|
|
896
|
-
- `options` - Configuration options for the module
|
|
897
|
-
|
|
898
|
-
**Returns:** `DynamicModule`
|
|
899
|
-
|
|
900
|
-
#### `ConfigModule.forRootAsync(options: NestConfigAwsModuleAsyncOptions)`
|
|
901
|
-
|
|
902
|
-
Configures the module asynchronously using a factory function.
|
|
903
|
-
|
|
904
|
-
**Parameters:**
|
|
905
|
-
- `options` - Async configuration options
|
|
906
|
-
|
|
907
|
-
**Returns:** `DynamicModule`
|
|
908
|
-
|
|
909
|
-
### ConfigService
|
|
910
|
-
|
|
911
|
-
#### `get<K extends keyof T>(key: K): T[K]`
|
|
912
|
-
|
|
913
|
-
Retrieves a configuration value by key with type safety.
|
|
914
|
-
|
|
915
|
-
**Parameters:**
|
|
916
|
-
- `key` - The configuration key to retrieve
|
|
917
|
-
|
|
918
|
-
**Returns:** The configuration value with proper typing
|
|
919
|
-
|
|
920
|
-
#### `getAll(): T`
|
|
921
|
-
|
|
922
|
-
Retrieves all configuration values.
|
|
923
|
-
|
|
924
|
-
**Returns:** The complete configuration object
|
|
925
|
-
|
|
926
|
-
#### `isInitialized(): boolean`
|
|
927
|
-
|
|
928
|
-
Checks if the configuration service has been initialized.
|
|
929
|
-
|
|
930
|
-
**Returns:** `true` if the service is ready to serve configuration values
|
|
931
|
-
|
|
932
|
-
### Configuration Loaders
|
|
933
|
-
|
|
934
|
-
#### EnvironmentLoader
|
|
935
|
-
|
|
936
|
-
Loads configuration from `process.env`.
|
|
937
|
-
|
|
938
|
-
#### SecretsManagerLoader
|
|
939
|
-
|
|
940
|
-
Loads configuration from AWS Secrets Manager with environment-aware path construction.
|
|
941
|
-
|
|
942
|
-
#### SSMParameterStoreLoader
|
|
943
|
-
|
|
944
|
-
Loads configuration from AWS Systems Manager Parameter Store with recursive parameter fetching.
|
|
945
|
-
|
|
946
|
-
## Troubleshooting
|
|
947
|
-
|
|
948
|
-
### Common Issues
|
|
949
|
-
|
|
950
|
-
#### 1. AWS Credentials Not Found
|
|
951
|
-
|
|
952
|
-
**Error:** `CredentialsProviderError: Could not load credentials`
|
|
953
|
-
|
|
954
|
-
**Solution:**
|
|
955
|
-
- Ensure AWS credentials are configured via AWS CLI, environment variables, or IAM roles
|
|
956
|
-
- For local development, set up an AWS profile: `aws configure --profile myprofile`
|
|
957
|
-
- Set `AWS_PROFILE` environment variable to use a specific profile
|
|
958
|
-
|
|
959
|
-
#### 2. Configuration Validation Errors
|
|
960
|
-
|
|
961
|
-
**Error:** `ValidationError: Configuration validation failed`
|
|
962
|
-
|
|
963
|
-
**Solution:**
|
|
964
|
-
- Check that all required environment variables are set
|
|
965
|
-
- Verify that configuration values match the expected types in your Zod schema
|
|
966
|
-
- Use `ignoreValidationErrors: true` for debugging (not recommended for production)
|
|
967
|
-
|
|
968
|
-
#### 3. AWS Region Not Detected
|
|
969
|
-
|
|
970
|
-
**Error:** `ConfigurationError: AWS region could not be determined`
|
|
971
|
-
|
|
972
|
-
**Solution:**
|
|
973
|
-
- Set the `AWS_REGION` environment variable
|
|
974
|
-
- Configure region in AWS credentials file
|
|
975
|
-
- Specify region in module configuration
|
|
976
|
-
|
|
977
|
-
#### 4. Secrets Manager Access Denied
|
|
978
|
-
|
|
979
|
-
**Error:** `AccessDenied: User is not authorized to perform secretsmanager:GetSecretValue`
|
|
980
|
-
|
|
981
|
-
**Solution:**
|
|
982
|
-
- Ensure your AWS credentials have the necessary permissions
|
|
983
|
-
- Add the following IAM policy to your user/role:
|
|
321
|
+
import { Injectable } from '@nestjs/common';
|
|
322
|
+
import { ConfigService, ConfigServiceImpl } from '@dyanet/nestjs-config-aws';
|
|
984
323
|
|
|
985
|
-
|
|
986
|
-
{
|
|
987
|
-
|
|
988
|
-
"Statement": [
|
|
989
|
-
{
|
|
990
|
-
"Effect": "Allow",
|
|
991
|
-
"Action": [
|
|
992
|
-
"secretsmanager:GetSecretValue",
|
|
993
|
-
"secretsmanager:DescribeSecret"
|
|
994
|
-
],
|
|
995
|
-
"Resource": "arn:aws:secretsmanager:*:*:secret:/myapp/*"
|
|
996
|
-
}
|
|
997
|
-
]
|
|
998
|
-
}
|
|
999
|
-
```
|
|
324
|
+
@Injectable()
|
|
325
|
+
export class MyService {
|
|
326
|
+
constructor(private readonly config: ConfigService) {}
|
|
1000
327
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
- Add the following IAM policy:
|
|
1007
|
-
|
|
1008
|
-
```json
|
|
1009
|
-
{
|
|
1010
|
-
"Version": "2012-10-17",
|
|
1011
|
-
"Statement": [
|
|
1012
|
-
{
|
|
1013
|
-
"Effect": "Allow",
|
|
1014
|
-
"Action": [
|
|
1015
|
-
"ssm:GetParameter",
|
|
1016
|
-
"ssm:GetParameters",
|
|
1017
|
-
"ssm:GetParametersByPath"
|
|
1018
|
-
],
|
|
1019
|
-
"Resource": "arn:aws:ssm:*:*:parameter/myapp/*"
|
|
1020
|
-
}
|
|
1021
|
-
]
|
|
328
|
+
getLoadResult() {
|
|
329
|
+
// Access ConfigManager directly
|
|
330
|
+
const impl = this.config as ConfigServiceImpl;
|
|
331
|
+
return impl.getConfigManager().getLoadResult();
|
|
332
|
+
}
|
|
1022
333
|
}
|
|
1023
334
|
```
|
|
1024
335
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
**Problem:** Configuration service returns undefined values
|
|
1028
|
-
|
|
1029
|
-
**Solution:**
|
|
1030
|
-
- Ensure the module is imported in your root module
|
|
1031
|
-
- Check that the configuration service is properly injected
|
|
1032
|
-
- Verify that `APP_ENV` is set correctly
|
|
1033
|
-
- Check AWS credentials and permissions
|
|
1034
|
-
|
|
1035
|
-
#### 7. Type Safety Issues
|
|
1036
|
-
|
|
1037
|
-
**Problem:** TypeScript errors when accessing configuration
|
|
1038
|
-
|
|
1039
|
-
**Solution:**
|
|
1040
|
-
- Ensure you're using the correct generic type for `ConfigService<T>`
|
|
1041
|
-
- Verify your Zod schema matches your configuration interface
|
|
1042
|
-
- Use type assertion if necessary: `configService.get('KEY' as keyof T)`
|
|
1043
|
-
|
|
1044
|
-
#### 8. @nestjs/config Integration Issues
|
|
1045
|
-
|
|
1046
|
-
**Problem:** Configuration not loading from AWS when using integration
|
|
1047
|
-
|
|
1048
|
-
**Solution:**
|
|
1049
|
-
- Ensure `NestConfigAwsIntegrationModule` is imported before `ConfigModule`
|
|
1050
|
-
- Check that AWS credentials are properly configured
|
|
1051
|
-
- Verify precedence rules are set correctly
|
|
1052
|
-
- Enable logging to debug configuration loading: `enableLogging: true`
|
|
1053
|
-
|
|
1054
|
-
**Problem:** Precedence rules not working as expected
|
|
1055
|
-
|
|
1056
|
-
**Solution:**
|
|
1057
|
-
- Check precedence configuration: `'aws-first'`, `'local-first'`, or `'merge'`
|
|
1058
|
-
- Verify that both local and AWS sources have the same configuration keys
|
|
1059
|
-
- Use debug logging to see which values are being used
|
|
336
|
+
## Re-exported Types
|
|
1060
337
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
**Solution:**
|
|
1064
|
-
- Ensure namespace names in integration config match `registerAs` names
|
|
1065
|
-
- Check that AWS sources contain the expected namespace structure
|
|
1066
|
-
- Verify that `registerAs` factories are properly loaded by `ConfigModule`
|
|
1067
|
-
|
|
1068
|
-
### Debug Mode
|
|
1069
|
-
|
|
1070
|
-
Enable debug logging by setting the `DEBUG` environment variable:
|
|
1071
|
-
|
|
1072
|
-
```bash
|
|
1073
|
-
DEBUG=nestjs-config-aws* npm start
|
|
1074
|
-
```
|
|
1075
|
-
|
|
1076
|
-
This will provide detailed logs about:
|
|
1077
|
-
- Configuration loading steps
|
|
1078
|
-
- AWS service calls
|
|
1079
|
-
- Validation results
|
|
1080
|
-
- Error details
|
|
1081
|
-
|
|
1082
|
-
### Performance Considerations
|
|
1083
|
-
|
|
1084
|
-
#### Configuration Caching
|
|
1085
|
-
|
|
1086
|
-
The module caches configuration after the initial load. To force a reload:
|
|
338
|
+
All types from `@dyanet/config-aws` are re-exported for convenience:
|
|
1087
339
|
|
|
1088
340
|
```typescript
|
|
1089
|
-
|
|
1090
|
-
//
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
For a complete local environment with AWS service emulation:
|
|
1119
|
-
|
|
1120
|
-
```bash
|
|
1121
|
-
cd examples/docker-compose
|
|
1122
|
-
docker-compose up -d
|
|
1123
|
-
```
|
|
1124
|
-
|
|
1125
|
-
## Contributing
|
|
1126
|
-
|
|
1127
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
1128
|
-
|
|
1129
|
-
### Development Setup
|
|
1130
|
-
|
|
1131
|
-
```bash
|
|
1132
|
-
# Clone the repository
|
|
1133
|
-
git clone <repository-url>
|
|
1134
|
-
cd nestjs-config-aws
|
|
1135
|
-
|
|
1136
|
-
# Install dependencies
|
|
1137
|
-
npm install
|
|
1138
|
-
|
|
1139
|
-
# Run tests
|
|
1140
|
-
npm test
|
|
1141
|
-
|
|
1142
|
-
# Run tests in watch mode
|
|
1143
|
-
npm run test:watch
|
|
1144
|
-
|
|
1145
|
-
# Build the package
|
|
1146
|
-
npm run build
|
|
1147
|
-
|
|
1148
|
-
# Run linting
|
|
1149
|
-
npm run lint
|
|
341
|
+
import {
|
|
342
|
+
// Loaders
|
|
343
|
+
EnvironmentLoader,
|
|
344
|
+
EnvFileLoader,
|
|
345
|
+
S3Loader,
|
|
346
|
+
SecretsManagerLoader,
|
|
347
|
+
SSMParameterStoreLoader,
|
|
348
|
+
|
|
349
|
+
// ConfigManager
|
|
350
|
+
ConfigManager,
|
|
351
|
+
|
|
352
|
+
// Error classes
|
|
353
|
+
ConfigurationError,
|
|
354
|
+
ValidationError,
|
|
355
|
+
AWSServiceError,
|
|
356
|
+
ConfigurationLoadError,
|
|
357
|
+
MissingConfigurationError,
|
|
358
|
+
|
|
359
|
+
// Utilities
|
|
360
|
+
ConfigValidationUtil,
|
|
361
|
+
EnvFileParser,
|
|
362
|
+
|
|
363
|
+
// Types
|
|
364
|
+
ConfigLoader,
|
|
365
|
+
ConfigManagerOptions,
|
|
366
|
+
LoaderPrecedence,
|
|
367
|
+
VerboseOptions,
|
|
368
|
+
} from '@dyanet/nestjs-config-aws';
|
|
1150
369
|
```
|
|
1151
370
|
|
|
1152
|
-
|
|
371
|
+
## Related Packages
|
|
1153
372
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
npm run test:unit
|
|
1157
|
-
|
|
1158
|
-
# Integration tests (requires AWS credentials)
|
|
1159
|
-
npm run test:integration
|
|
1160
|
-
|
|
1161
|
-
# Coverage report
|
|
1162
|
-
npm run test:coverage
|
|
1163
|
-
```
|
|
373
|
+
- **[@dyanet/config-aws](../config-aws)** - Framework-agnostic core library
|
|
374
|
+
- **[@dyanet/nextjs-config-aws](../nextjs-config-aws)** - Next.js adapter
|
|
1164
375
|
|
|
1165
376
|
## License
|
|
1166
377
|
|
|
1167
|
-
MIT
|
|
1168
|
-
|
|
1169
|
-
---
|
|
1170
|
-
|
|
1171
|
-
## Changelog
|
|
1172
|
-
|
|
1173
|
-
### v1.0.0 - First Public Release 🎉
|
|
1174
|
-
- **Core Features**: Environment variable loading, AWS Secrets Manager, and SSM Parameter Store integration
|
|
1175
|
-
- **@nestjs/config Integration**: Seamless compatibility with standard NestJS configuration patterns
|
|
1176
|
-
- **Type Safety**: Full TypeScript support with Zod validation and generic types
|
|
1177
|
-
- **Environment Awareness**: Automatic configuration based on APP_ENV (local, development, test, production)
|
|
1178
|
-
- **Flexible Precedence**: aws-first, local-first, and merge strategies for configuration conflicts
|
|
1179
|
-
- **Performance Optimized**: Efficient loading with caching and pagination support
|
|
1180
|
-
- **Comprehensive Documentation**: Complete API reference, troubleshooting guide, and multiple examples
|
|
1181
|
-
- **Production Ready**: Robust error handling, security best practices, and monitoring support
|
|
1182
|
-
|
|
1183
|
-
See [CHANGELOG.md](CHANGELOG.md) for detailed release notes.
|
|
378
|
+
MIT
|