@dyanet/nestjs-config-aws 1.0.1 → 1.2.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/README.md +213 -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 +169 -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 +366 -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 +595 -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 +165 -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 +363 -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 +589 -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 +20 -27
- 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,383 @@
|
|
|
1
|
-
# nestjs-config-aws
|
|
1
|
+
# @dyanet/nestjs-config-aws
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@dyanet/nestjs-config-aws)
|
|
4
|
+
[](https://github.com/dyanet/config-aws/actions/workflows/ci.yml)
|
|
5
|
+
[](https://codecov.io/gh/dyanet/config-aws)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
NestJS adapter for AWS configuration management. A thin wrapper around [@dyanet/config-aws](../config-aws) that provides NestJS dependency injection and module patterns.
|
|
4
9
|
|
|
5
10
|
## Features
|
|
6
11
|
|
|
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)
|
|
12
|
+
- **NestJS Integration** - Full dependency injection support with `ConfigModule` and `ConfigService`
|
|
13
|
+
- **@nestjs/config Compatibility** - Seamless integration with the standard NestJS config module
|
|
14
|
+
- **Type Safety** - Full TypeScript support with Zod schema validation
|
|
15
|
+
- **AWS Services** - Load configuration from Secrets Manager, SSM Parameter Store, S3
|
|
16
|
+
- **Thin Adapter** - Minimal overhead, delegates to `@dyanet/config-aws` for all heavy lifting
|
|
31
17
|
|
|
32
18
|
## Installation
|
|
33
19
|
|
|
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
20
|
```bash
|
|
45
|
-
npm install nestjs-config-aws
|
|
21
|
+
npm install @dyanet/nestjs-config-aws
|
|
46
22
|
```
|
|
47
23
|
|
|
48
24
|
### Peer Dependencies
|
|
49
25
|
|
|
50
|
-
Make sure you have the following peer dependencies installed:
|
|
51
|
-
|
|
52
26
|
```bash
|
|
53
|
-
npm install @nestjs/common @nestjs/core zod
|
|
27
|
+
npm install @nestjs/common @nestjs/core @nestjs/config zod
|
|
54
28
|
```
|
|
55
29
|
|
|
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:
|
|
68
|
-
|
|
69
|
-
### Option 1: Standalone Usage
|
|
30
|
+
For AWS services, install the SDK clients you need:
|
|
70
31
|
|
|
71
|
-
|
|
32
|
+
```bash
|
|
33
|
+
# For Secrets Manager
|
|
34
|
+
npm install @aws-sdk/client-secrets-manager
|
|
72
35
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
import { ConfigModule } from 'nestjs-config-aws';
|
|
36
|
+
# For SSM Parameter Store
|
|
37
|
+
npm install @aws-sdk/client-ssm
|
|
76
38
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
ConfigModule.forRoot(), // Uses default configuration
|
|
80
|
-
],
|
|
81
|
-
})
|
|
82
|
-
export class AppModule {}
|
|
39
|
+
# For S3
|
|
40
|
+
npm install @aws-sdk/client-s3
|
|
83
41
|
```
|
|
84
42
|
|
|
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
|
-
```
|
|
43
|
+
## Quick Start
|
|
108
44
|
|
|
109
|
-
###
|
|
45
|
+
### Basic Usage
|
|
110
46
|
|
|
111
47
|
```typescript
|
|
48
|
+
// app.module.ts
|
|
112
49
|
import { Module } from '@nestjs/common';
|
|
113
|
-
import { ConfigModule } from 'nestjs-config-aws';
|
|
50
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
114
51
|
import { z } from 'zod';
|
|
115
52
|
|
|
116
53
|
const configSchema = z.object({
|
|
117
|
-
PORT: z.coerce.number().default(3000),
|
|
118
54
|
DATABASE_URL: z.string(),
|
|
119
55
|
API_KEY: z.string(),
|
|
120
|
-
|
|
56
|
+
PORT: z.coerce.number().default(3000),
|
|
121
57
|
});
|
|
122
58
|
|
|
123
59
|
@Module({
|
|
124
60
|
imports: [
|
|
125
61
|
ConfigModule.forRoot({
|
|
126
62
|
schema: configSchema,
|
|
63
|
+
envPrefix: 'APP_',
|
|
64
|
+
secretsManagerConfig: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
region: 'us-east-1',
|
|
67
|
+
},
|
|
127
68
|
}),
|
|
128
69
|
],
|
|
129
70
|
})
|
|
130
71
|
export class AppModule {}
|
|
131
72
|
```
|
|
132
73
|
|
|
133
|
-
###
|
|
134
|
-
|
|
135
|
-
Both approaches use the same service patterns:
|
|
74
|
+
### Using ConfigService
|
|
136
75
|
|
|
137
76
|
```typescript
|
|
77
|
+
// app.service.ts
|
|
138
78
|
import { Injectable } from '@nestjs/common';
|
|
139
|
-
|
|
140
|
-
// For integration: import { ConfigService } from '@nestjs/config';
|
|
141
|
-
import { ConfigService } from '@nestjs/config';
|
|
79
|
+
import { ConfigService } from '@dyanet/nestjs-config-aws';
|
|
142
80
|
|
|
143
81
|
@Injectable()
|
|
144
82
|
export class AppService {
|
|
145
|
-
constructor(private
|
|
83
|
+
constructor(private readonly config: ConfigService) {}
|
|
146
84
|
|
|
147
|
-
getPort(): number {
|
|
148
|
-
return this.configService.get('PORT'); // Values can come from AWS
|
|
149
|
-
}
|
|
150
|
-
|
|
151
85
|
getDatabaseUrl(): string {
|
|
152
|
-
|
|
153
|
-
return this.configService.get('DATABASE_URL');
|
|
86
|
+
return this.config.get('DATABASE_URL');
|
|
154
87
|
}
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## Configuration
|
|
159
|
-
|
|
160
|
-
### Module Options
|
|
161
88
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
interface NestConfigAwsModuleOptions<T = any> {
|
|
166
|
-
schema?: ZodType<T>;
|
|
167
|
-
secretsManagerConfig?: SecretsManagerConfig;
|
|
168
|
-
ssmConfig?: SSMConfig;
|
|
169
|
-
envPrefix?: string;
|
|
170
|
-
ignoreValidationErrors?: boolean;
|
|
171
|
-
appEnvVariable?: string;
|
|
172
|
-
loadSync?: boolean;
|
|
89
|
+
getPort(): number {
|
|
90
|
+
return this.config.get('PORT');
|
|
91
|
+
}
|
|
173
92
|
}
|
|
174
93
|
```
|
|
175
94
|
|
|
176
|
-
|
|
95
|
+
## ConfigModule
|
|
177
96
|
|
|
178
|
-
|
|
179
|
-
interface SecretsManagerConfig {
|
|
180
|
-
region?: string;
|
|
181
|
-
paths?: {
|
|
182
|
-
development?: string;
|
|
183
|
-
test?: string;
|
|
184
|
-
production?: string;
|
|
185
|
-
};
|
|
186
|
-
enabled?: boolean;
|
|
187
|
-
}
|
|
188
|
-
```
|
|
97
|
+
### forRoot()
|
|
189
98
|
|
|
190
|
-
|
|
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;
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Environment Variables
|
|
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) {}
|
|
269
|
-
|
|
270
|
-
getDatabaseUrl(): string {
|
|
271
|
-
return this.configService.get('DATABASE_URL');
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Custom Schema with Validation
|
|
99
|
+
Synchronous module registration with static options:
|
|
277
100
|
|
|
278
101
|
```typescript
|
|
102
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
279
103
|
import { z } from 'zod';
|
|
280
104
|
|
|
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),
|
|
105
|
+
const schema = z.object({
|
|
106
|
+
DATABASE_URL: z.string(),
|
|
107
|
+
PORT: z.coerce.number().default(3000),
|
|
297
108
|
});
|
|
298
109
|
|
|
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
110
|
@Module({
|
|
315
111
|
imports: [
|
|
316
112
|
ConfigModule.forRoot({
|
|
317
|
-
schema
|
|
113
|
+
schema,
|
|
114
|
+
envPrefix: 'APP_',
|
|
318
115
|
secretsManagerConfig: {
|
|
116
|
+
enabled: true,
|
|
319
117
|
region: 'us-east-1',
|
|
320
118
|
paths: {
|
|
321
|
-
development: '
|
|
322
|
-
|
|
323
|
-
production: '/myapp/prod/secrets',
|
|
119
|
+
development: 'dev/',
|
|
120
|
+
production: 'prod/',
|
|
324
121
|
},
|
|
325
|
-
enabled: true,
|
|
326
122
|
},
|
|
327
123
|
ssmConfig: {
|
|
124
|
+
enabled: true,
|
|
328
125
|
region: 'us-east-1',
|
|
126
|
+
decrypt: true,
|
|
329
127
|
paths: {
|
|
330
|
-
development: '/
|
|
331
|
-
|
|
332
|
-
production: '/myapp/prod/config/',
|
|
128
|
+
development: '/app/dev',
|
|
129
|
+
production: '/app/prod',
|
|
333
130
|
},
|
|
334
|
-
enabled: true,
|
|
335
|
-
decrypt: true,
|
|
336
131
|
},
|
|
337
|
-
envPrefix: 'MYAPP_',
|
|
338
132
|
}),
|
|
339
133
|
],
|
|
340
134
|
})
|
|
341
135
|
export class AppModule {}
|
|
342
136
|
```
|
|
343
137
|
|
|
344
|
-
###
|
|
138
|
+
### forRootAsync()
|
|
139
|
+
|
|
140
|
+
Asynchronous module registration with factory function:
|
|
345
141
|
|
|
346
142
|
```typescript
|
|
143
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
144
|
+
import { SomeService } from './some.service';
|
|
145
|
+
|
|
347
146
|
@Module({
|
|
348
147
|
imports: [
|
|
349
148
|
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,
|
|
149
|
+
imports: [SomeModule],
|
|
150
|
+
inject: [SomeService],
|
|
151
|
+
useFactory: async (someService: SomeService) => ({
|
|
152
|
+
schema: someService.getConfigSchema(),
|
|
153
|
+
envPrefix: 'APP_',
|
|
395
154
|
secretsManagerConfig: {
|
|
396
155
|
enabled: true,
|
|
397
|
-
|
|
156
|
+
region: await someService.getAwsRegion(),
|
|
398
157
|
},
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
},
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
default:
|
|
406
|
-
return baseConfig;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
@Module({
|
|
411
|
-
imports: [ConfigModule.forRoot(getConfigForEnvironment())],
|
|
158
|
+
}),
|
|
159
|
+
}),
|
|
160
|
+
],
|
|
412
161
|
})
|
|
413
162
|
export class AppModule {}
|
|
414
163
|
```
|
|
415
164
|
|
|
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
|
|
165
|
+
### Module Options
|
|
421
166
|
|
|
422
|
-
|
|
167
|
+
| Option | Type | Default | Description |
|
|
168
|
+
|--------|------|---------|-------------|
|
|
169
|
+
| `schema` | `ZodType<T>` | Default schema | Zod schema for validation |
|
|
170
|
+
| `envPrefix` | `string` | `undefined` | Prefix for environment variables |
|
|
171
|
+
| `secretsManagerConfig` | `SecretsManagerConfig` | `undefined` | Secrets Manager configuration |
|
|
172
|
+
| `ssmConfig` | `SSMConfig` | `undefined` | SSM Parameter Store configuration |
|
|
173
|
+
| `ignoreValidationErrors` | `boolean` | `false` | Continue with partial config on validation errors |
|
|
174
|
+
| `loadSync` | `boolean` | `false` | Load configuration synchronously |
|
|
423
175
|
|
|
424
|
-
|
|
425
|
-
npm install nestjs-config-aws @nestjs/config
|
|
426
|
-
```
|
|
176
|
+
#### SecretsManagerConfig
|
|
427
177
|
|
|
428
|
-
|
|
178
|
+
| Option | Type | Default | Description |
|
|
179
|
+
|--------|------|---------|-------------|
|
|
180
|
+
| `enabled` | `boolean` | `true` | Enable Secrets Manager integration |
|
|
181
|
+
| `region` | `string` | `undefined` | AWS region |
|
|
182
|
+
| `paths` | `object` | `undefined` | Environment-specific path prefixes |
|
|
429
183
|
|
|
430
|
-
|
|
431
|
-
import { Module } from '@nestjs/common';
|
|
432
|
-
import { ConfigModule } from '@nestjs/config';
|
|
433
|
-
import { NestConfigAwsIntegrationModule } from 'nestjs-config-aws';
|
|
184
|
+
#### SSMConfig
|
|
434
185
|
|
|
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
|
-
```
|
|
186
|
+
| Option | Type | Default | Description |
|
|
187
|
+
|--------|------|---------|-------------|
|
|
188
|
+
| `enabled` | `boolean` | `true` | Enable SSM Parameter Store integration |
|
|
189
|
+
| `region` | `string` | `undefined` | AWS region |
|
|
190
|
+
| `decrypt` | `boolean` | `true` | Decrypt SecureString parameters |
|
|
191
|
+
| `paths` | `object` | `undefined` | Environment-specific path prefixes |
|
|
457
192
|
|
|
458
|
-
|
|
193
|
+
## ConfigService
|
|
459
194
|
|
|
460
|
-
|
|
195
|
+
The `ConfigService` is automatically registered as a global provider:
|
|
461
196
|
|
|
462
197
|
```typescript
|
|
463
198
|
import { Injectable } from '@nestjs/common';
|
|
464
|
-
import { ConfigService } from '@nestjs
|
|
199
|
+
import { ConfigService } from '@dyanet/nestjs-config-aws';
|
|
465
200
|
|
|
466
201
|
@Injectable()
|
|
467
|
-
export class
|
|
468
|
-
constructor(private
|
|
202
|
+
export class MyService {
|
|
203
|
+
constructor(private readonly config: ConfigService) {}
|
|
469
204
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return this.
|
|
205
|
+
// Get a specific value
|
|
206
|
+
getValue(): string {
|
|
207
|
+
return this.config.get('MY_KEY');
|
|
473
208
|
}
|
|
474
209
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
return this.
|
|
210
|
+
// Get all configuration
|
|
211
|
+
getAllConfig() {
|
|
212
|
+
return this.config.getAll();
|
|
478
213
|
}
|
|
479
|
-
}
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### Integration Configuration Options
|
|
483
214
|
|
|
484
|
-
|
|
215
|
+
// Check if initialized
|
|
216
|
+
isReady(): boolean {
|
|
217
|
+
return this.config.isInitialized();
|
|
218
|
+
}
|
|
485
219
|
|
|
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;
|
|
220
|
+
// Get current environment
|
|
221
|
+
getEnvironment(): string {
|
|
222
|
+
return this.config.getAppEnv();
|
|
223
|
+
}
|
|
507
224
|
}
|
|
508
225
|
```
|
|
509
226
|
|
|
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
|
|
227
|
+
## @nestjs/config Integration
|
|
539
228
|
|
|
540
|
-
|
|
229
|
+
Use `NestConfigAwsIntegrationModule` for seamless integration with `@nestjs/config`:
|
|
541
230
|
|
|
542
231
|
```typescript
|
|
543
232
|
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:
|
|
233
|
+
import { ConfigModule as NestConfigModule } from '@nestjs/config';
|
|
234
|
+
import { NestConfigAwsIntegrationModule } from '@dyanet/nestjs-config-aws';
|
|
584
235
|
|
|
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
236
|
@Module({
|
|
598
237
|
imports: [
|
|
238
|
+
NestConfigModule.forRoot(),
|
|
599
239
|
NestConfigAwsIntegrationModule.forRoot({
|
|
600
|
-
|
|
601
|
-
secretsManagerConfig: {
|
|
602
|
-
enabled: true,
|
|
603
|
-
paths: {
|
|
604
|
-
production: '/myapp/prod/database'
|
|
605
|
-
}
|
|
606
|
-
}
|
|
240
|
+
registerGlobally: true,
|
|
607
241
|
}),
|
|
608
|
-
|
|
609
|
-
ConfigModule.forRoot({
|
|
610
|
-
load: [databaseConfig],
|
|
611
|
-
isGlobal: true
|
|
612
|
-
})
|
|
613
|
-
]
|
|
242
|
+
],
|
|
614
243
|
})
|
|
615
244
|
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
245
|
```
|
|
631
246
|
|
|
632
|
-
###
|
|
633
|
-
|
|
634
|
-
The integration works seamlessly with @nestjs/config validation:
|
|
635
|
-
|
|
636
|
-
#### Using Joi Validation
|
|
247
|
+
### Async Integration
|
|
637
248
|
|
|
638
249
|
```typescript
|
|
639
|
-
import
|
|
250
|
+
import { NestConfigAwsIntegrationModule } from '@dyanet/nestjs-config-aws';
|
|
640
251
|
|
|
641
252
|
@Module({
|
|
642
253
|
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
|
|
254
|
+
NestConfigAwsIntegrationModule.forRootAsync({
|
|
255
|
+
imports: [SomeModule],
|
|
256
|
+
inject: [SomeService],
|
|
257
|
+
useFactory: async (someService: SomeService) => ({
|
|
258
|
+
registerGlobally: true,
|
|
259
|
+
// Additional options from someService
|
|
655
260
|
}),
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
abortEarly: false,
|
|
659
|
-
}
|
|
660
|
-
})
|
|
661
|
-
]
|
|
261
|
+
}),
|
|
262
|
+
],
|
|
662
263
|
})
|
|
663
264
|
export class AppModule {}
|
|
664
265
|
```
|
|
665
266
|
|
|
666
|
-
|
|
267
|
+
## Migration from Monolithic Package
|
|
667
268
|
|
|
668
|
-
|
|
669
|
-
import { IsString, IsNumber, IsUrl } from 'class-validator';
|
|
670
|
-
import { Transform } from 'class-transformer';
|
|
269
|
+
If you're upgrading from an older version of `@dyanet/nestjs-config-aws` that included all functionality in one package:
|
|
671
270
|
|
|
672
|
-
|
|
673
|
-
@IsString()
|
|
674
|
-
NODE_ENV: string;
|
|
271
|
+
### What Changed
|
|
675
272
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
273
|
+
1. **Core functionality moved to `@dyanet/config-aws`** - All loaders, ConfigManager, and utilities are now in the core package
|
|
274
|
+
2. **This package is now a thin adapter** - It re-exports everything from `@dyanet/config-aws` and adds NestJS-specific integration
|
|
275
|
+
3. **Same API surface** - The public API remains the same for backward compatibility
|
|
679
276
|
|
|
680
|
-
|
|
681
|
-
DATABASE_URL: string; // Can come from AWS
|
|
277
|
+
### Migration Steps
|
|
682
278
|
|
|
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:
|
|
279
|
+
1. **No code changes required** - The package re-exports all types and classes from `@dyanet/config-aws`
|
|
280
|
+
2. **Optional: Use core package directly** - For non-NestJS code, you can import from `@dyanet/config-aws` directly
|
|
716
281
|
|
|
717
282
|
```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
|
-
```
|
|
283
|
+
// Before (still works)
|
|
284
|
+
import { EnvironmentLoader, ConfigManager } from '@dyanet/nestjs-config-aws';
|
|
733
285
|
|
|
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
|
-
})
|
|
286
|
+
// After (optional, for non-NestJS code)
|
|
287
|
+
import { EnvironmentLoader, ConfigManager } from '@dyanet/config-aws';
|
|
825
288
|
```
|
|
826
289
|
|
|
827
|
-
|
|
290
|
+
## Advanced Usage
|
|
828
291
|
|
|
829
|
-
|
|
830
|
-
```typescript
|
|
831
|
-
NestConfigAwsIntegrationModule.forRootAsync({
|
|
832
|
-
useFactory: async () => {
|
|
833
|
-
// Async setup ensures proper initialization order
|
|
834
|
-
return { secretsManagerConfig: { enabled: true } };
|
|
835
|
-
}
|
|
836
|
-
})
|
|
837
|
-
```
|
|
292
|
+
### Custom Loaders
|
|
838
293
|
|
|
839
|
-
|
|
294
|
+
Use loaders from `@dyanet/config-aws` directly:
|
|
840
295
|
|
|
841
|
-
Verify precedence configuration:
|
|
842
296
|
```typescript
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
297
|
+
import { ConfigModule } from '@dyanet/nestjs-config-aws';
|
|
298
|
+
import {
|
|
299
|
+
EnvironmentLoader,
|
|
300
|
+
EnvFileLoader,
|
|
301
|
+
S3Loader,
|
|
302
|
+
SecretsManagerLoader,
|
|
303
|
+
SSMParameterStoreLoader,
|
|
304
|
+
ConfigManager
|
|
305
|
+
} from '@dyanet/nestjs-config-aws';
|
|
306
|
+
|
|
307
|
+
// Create custom ConfigManager
|
|
308
|
+
const configManager = new ConfigManager({
|
|
309
|
+
loaders: [
|
|
310
|
+
new EnvironmentLoader({ prefix: 'APP_' }),
|
|
311
|
+
new EnvFileLoader({ paths: ['.env', '.env.local'] }),
|
|
312
|
+
new S3Loader({ bucket: 'my-bucket', key: 'config.json' }),
|
|
313
|
+
new SecretsManagerLoader({ secretName: '/my-app/secrets' }),
|
|
314
|
+
new SSMParameterStoreLoader({ parameterPath: '/my-app/params' }),
|
|
315
|
+
],
|
|
316
|
+
precedence: 'aws-first',
|
|
317
|
+
verbose: true,
|
|
318
|
+
});
|
|
847
319
|
```
|
|
848
320
|
|
|
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
|
-
```
|
|
321
|
+
### Accessing ConfigManager
|
|
859
322
|
|
|
860
|
-
|
|
323
|
+
Get the underlying `ConfigManager` for advanced use cases:
|
|
861
324
|
|
|
862
|
-
Ensure namespace configuration matches registerAs usage:
|
|
863
325
|
```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:
|
|
326
|
+
import { Injectable } from '@nestjs/common';
|
|
327
|
+
import { ConfigService, ConfigServiceImpl } from '@dyanet/nestjs-config-aws';
|
|
984
328
|
|
|
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
|
-
```
|
|
329
|
+
@Injectable()
|
|
330
|
+
export class MyService {
|
|
331
|
+
constructor(private readonly config: ConfigService) {}
|
|
1000
332
|
|
|
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
|
-
]
|
|
333
|
+
getLoadResult() {
|
|
334
|
+
// Access ConfigManager directly
|
|
335
|
+
const impl = this.config as ConfigServiceImpl;
|
|
336
|
+
return impl.getConfigManager().getLoadResult();
|
|
337
|
+
}
|
|
1022
338
|
}
|
|
1023
339
|
```
|
|
1024
340
|
|
|
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
|
|
341
|
+
## Re-exported Types
|
|
1060
342
|
|
|
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:
|
|
343
|
+
All types from `@dyanet/config-aws` are re-exported for convenience:
|
|
1087
344
|
|
|
1088
345
|
```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
|
|
346
|
+
import {
|
|
347
|
+
// Loaders
|
|
348
|
+
EnvironmentLoader,
|
|
349
|
+
EnvFileLoader,
|
|
350
|
+
S3Loader,
|
|
351
|
+
SecretsManagerLoader,
|
|
352
|
+
SSMParameterStoreLoader,
|
|
353
|
+
|
|
354
|
+
// ConfigManager
|
|
355
|
+
ConfigManager,
|
|
356
|
+
|
|
357
|
+
// Error classes
|
|
358
|
+
ConfigurationError,
|
|
359
|
+
ValidationError,
|
|
360
|
+
AWSServiceError,
|
|
361
|
+
ConfigurationLoadError,
|
|
362
|
+
MissingConfigurationError,
|
|
363
|
+
|
|
364
|
+
// Utilities
|
|
365
|
+
ConfigValidationUtil,
|
|
366
|
+
EnvFileParser,
|
|
367
|
+
|
|
368
|
+
// Types
|
|
369
|
+
ConfigLoader,
|
|
370
|
+
ConfigManagerOptions,
|
|
371
|
+
LoaderPrecedence,
|
|
372
|
+
VerboseOptions,
|
|
373
|
+
} from '@dyanet/nestjs-config-aws';
|
|
1150
374
|
```
|
|
1151
375
|
|
|
1152
|
-
|
|
376
|
+
## Related Packages
|
|
1153
377
|
|
|
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
|
-
```
|
|
378
|
+
- **[@dyanet/config-aws](../config-aws)** - Framework-agnostic core library
|
|
379
|
+
- **[@dyanet/nextjs-config-aws](../nextjs-config-aws)** - Next.js adapter
|
|
1164
380
|
|
|
1165
381
|
## License
|
|
1166
382
|
|
|
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.
|
|
383
|
+
MIT
|