@itgorillaz/configify 1.1.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/.prettierrc +4 -0
- package/LICENSE +21 -0
- package/README.md +281 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/src/configify.module.d.ts +12 -0
- package/dist/src/configify.module.js +120 -0
- package/dist/src/configify.module.js.map +1 -0
- package/dist/src/configuration/configuration-options.interface.d.ts +11 -0
- package/dist/src/configuration/configuration-options.interface.js +9 -0
- package/dist/src/configuration/configuration-options.interface.js.map +1 -0
- package/dist/src/configuration/configuration-parser.interface.d.ts +3 -0
- package/dist/src/configuration/configuration-parser.interface.js +3 -0
- package/dist/src/configuration/configuration-parser.interface.js.map +1 -0
- package/dist/src/configuration/configuration-providers.interface.d.ts +5 -0
- package/dist/src/configuration/configuration-providers.interface.js +3 -0
- package/dist/src/configuration/configuration-providers.interface.js.map +1 -0
- package/dist/src/configuration/configuration.registry.d.ts +9 -0
- package/dist/src/configuration/configuration.registry.js +25 -0
- package/dist/src/configuration/configuration.registry.js.map +1 -0
- package/dist/src/configuration/index.d.ts +6 -0
- package/dist/src/configuration/index.js +23 -0
- package/dist/src/configuration/index.js.map +1 -0
- package/dist/src/configuration/parsers/configuration-parser.factory.d.ts +7 -0
- package/dist/src/configuration/parsers/configuration-parser.factory.js +27 -0
- package/dist/src/configuration/parsers/configuration-parser.factory.js.map +1 -0
- package/dist/src/configuration/parsers/dotenv-configuration.parser.d.ts +4 -0
- package/dist/src/configuration/parsers/dotenv-configuration.parser.js +12 -0
- package/dist/src/configuration/parsers/dotenv-configuration.parser.js.map +1 -0
- package/dist/src/configuration/parsers/index.d.ts +4 -0
- package/dist/src/configuration/parsers/index.js +21 -0
- package/dist/src/configuration/parsers/index.js.map +1 -0
- package/dist/src/configuration/parsers/json-configuration.parser.d.ts +4 -0
- package/dist/src/configuration/parsers/json-configuration.parser.js +11 -0
- package/dist/src/configuration/parsers/json-configuration.parser.js.map +1 -0
- package/dist/src/configuration/parsers/yaml-configuration.parser.d.ts +4 -0
- package/dist/src/configuration/parsers/yaml-configuration.parser.js +12 -0
- package/dist/src/configuration/parsers/yaml-configuration.parser.js.map +1 -0
- package/dist/src/configuration/resolvers/aws/index.d.ts +2 -0
- package/dist/src/configuration/resolvers/aws/index.js +19 -0
- package/dist/src/configuration/resolvers/aws/index.js.map +1 -0
- package/dist/src/configuration/resolvers/aws/parameter-store-configuration.resolver.d.ts +12 -0
- package/dist/src/configuration/resolvers/aws/parameter-store-configuration.resolver.js +61 -0
- package/dist/src/configuration/resolvers/aws/parameter-store-configuration.resolver.js.map +1 -0
- package/dist/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.d.ts +12 -0
- package/dist/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.js +59 -0
- package/dist/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.js.map +1 -0
- package/dist/src/configuration/resolvers/configuration-resolver.interface.d.ts +3 -0
- package/dist/src/configuration/resolvers/configuration-resolver.interface.js +3 -0
- package/dist/src/configuration/resolvers/configuration-resolver.interface.js.map +1 -0
- package/dist/src/configuration/resolvers/index.d.ts +3 -0
- package/dist/src/configuration/resolvers/index.js +20 -0
- package/dist/src/configuration/resolvers/index.js.map +1 -0
- package/dist/src/configuration/resolvers/resolved-value.interface.d.ts +7 -0
- package/dist/src/configuration/resolvers/resolved-value.interface.js +3 -0
- package/dist/src/configuration/resolvers/resolved-value.interface.js.map +1 -0
- package/dist/src/decorators/configuration.decorator.d.ts +2 -0
- package/dist/src/decorators/configuration.decorator.js +13 -0
- package/dist/src/decorators/configuration.decorator.js.map +1 -0
- package/dist/src/decorators/index.d.ts +2 -0
- package/dist/src/decorators/index.js +19 -0
- package/dist/src/decorators/index.js.map +1 -0
- package/dist/src/decorators/value.decorator.d.ts +10 -0
- package/dist/src/decorators/value.decorator.js +14 -0
- package/dist/src/decorators/value.decorator.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +19 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interpolation/variables.d.ts +9 -0
- package/dist/src/interpolation/variables.js +37 -0
- package/dist/src/interpolation/variables.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/index.d.ts +1 -0
- package/index.js +6 -0
- package/index.ts +1 -0
- package/nest-cli.json +8 -0
- package/package.json +82 -0
- package/src/configify.module.ts +241 -0
- package/src/configuration/configuration-options.interface.ts +51 -0
- package/src/configuration/configuration-parser.interface.ts +15 -0
- package/src/configuration/configuration-providers.interface.ts +9 -0
- package/src/configuration/configuration.registry.ts +70 -0
- package/src/configuration/index.ts +6 -0
- package/src/configuration/parsers/configuration-parser.factory.ts +53 -0
- package/src/configuration/parsers/dotenv-configuration.parser.ts +18 -0
- package/src/configuration/parsers/index.ts +4 -0
- package/src/configuration/parsers/json-configuration.parser.ts +17 -0
- package/src/configuration/parsers/yaml-configuration.parser.ts +18 -0
- package/src/configuration/resolvers/aws/index.ts +2 -0
- package/src/configuration/resolvers/aws/parameter-store-configuration.resolver.ts +115 -0
- package/src/configuration/resolvers/aws/secrets-manager-configuration.resolver.ts +117 -0
- package/src/configuration/resolvers/configuration-resolver.interface.ts +11 -0
- package/src/configuration/resolvers/index.ts +3 -0
- package/src/configuration/resolvers/resolved-value.interface.ts +10 -0
- package/src/decorators/configuration.decorator.ts +26 -0
- package/src/decorators/index.ts +2 -0
- package/src/decorators/value.decorator.ts +47 -0
- package/src/index.ts +2 -0
- package/src/interpolation/variables.ts +101 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +21 -0
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ITGorillaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><b>@itgorillaz/configify</b></p>
|
|
6
|
+
<p align="center">NestJS config on steroids</p>
|
|
7
|
+
|
|
8
|
+
## Description
|
|
9
|
+
|
|
10
|
+
**configify** is a NestJS configuration module that makes it easier to deal with configuration files and secrets.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
$ npm install --save @itgorillaz/configify
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
To start using the <b>configify</b> module in your application import the module by calling the `forRootAsync` function:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
@Module({
|
|
24
|
+
imports: [ConfigifyModule.forRootAsync()],
|
|
25
|
+
controllers: [AppController],
|
|
26
|
+
providers: [AppService],
|
|
27
|
+
})
|
|
28
|
+
export class AppModule {}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
By default, when bootstraping, the module will lookup for a `.env` or an `application.yml` file at the root folder of the project:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
my-web-app
|
|
35
|
+
| .env
|
|
36
|
+
| application.yml
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You can also provide the location of the configuration files by overring the configuration options.
|
|
40
|
+
|
|
41
|
+
### Mapping Configuration Classes
|
|
42
|
+
|
|
43
|
+
This module will lookup for every class decorated with `@Configuration` and it will make its instance globally available for the application.
|
|
44
|
+
|
|
45
|
+
Example of a `.env` file mapped to a class:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
APPLICATION_CLIENT_ID=ABC
|
|
49
|
+
APPLICATION_CLIENT_TOKEN=TEST
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
@Configuration()
|
|
54
|
+
export class ApplicationClientConfig {
|
|
55
|
+
@Value('APPLICATION_CLIENT_ID')
|
|
56
|
+
appClientId: string;
|
|
57
|
+
|
|
58
|
+
@Value('APPLICATION_CLIENT_TOKEN')
|
|
59
|
+
appClientToken: string
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Example of a `.yml` file mapped to a class:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
database:
|
|
67
|
+
host: localhost
|
|
68
|
+
port: 3306
|
|
69
|
+
username: test
|
|
70
|
+
password: test
|
|
71
|
+
metadata: |
|
|
72
|
+
{
|
|
73
|
+
"label": "staging"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
@Configuration()
|
|
79
|
+
export class DatabaseConfiguration {
|
|
80
|
+
@Value('database.host')
|
|
81
|
+
host: string;
|
|
82
|
+
|
|
83
|
+
@Value('database.port', {
|
|
84
|
+
parse: (value: any) => parseInt(value)
|
|
85
|
+
})
|
|
86
|
+
port: number;
|
|
87
|
+
|
|
88
|
+
@Value('database.metadata', {
|
|
89
|
+
parse: (value: any) => JSON.parse(value)
|
|
90
|
+
})
|
|
91
|
+
metadata: MetadataType;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
You can map your configuration file to multiple configuration classes:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
# database config
|
|
99
|
+
DATABASE_HOST=localhost
|
|
100
|
+
DATABASE_USER=test
|
|
101
|
+
DATABASE_PASSWORD=test
|
|
102
|
+
|
|
103
|
+
# okta config
|
|
104
|
+
OKTA_API_TOKEN=test
|
|
105
|
+
OKTA_CLIENT_ID=test
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
@Configuration()
|
|
110
|
+
export class DatabaseConfiguration {
|
|
111
|
+
// database configuration attributes
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
@Configuration()
|
|
117
|
+
export class OktaConfiguration {
|
|
118
|
+
// okta configuration attributes
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Dependency Injection
|
|
123
|
+
|
|
124
|
+
This module makes all the configuration instances globally available to the application, to access it you just need to declare the configuration class as an argument in the class constructor:
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
export class AppService {
|
|
128
|
+
private readonly LOGGER = new Logger(AppService.name);
|
|
129
|
+
|
|
130
|
+
constructor(private readonly config: MyConfig) {
|
|
131
|
+
this.LOGGER.log(JSON.stringify(config));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Variables Expansion
|
|
138
|
+
|
|
139
|
+
You can make use of variable expasion in your configuration files:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
MY_API_KEY=${MY_SECRET} // --> MY_API_KEY=TEST
|
|
143
|
+
ANY_OTHER_CONFIG=TEST
|
|
144
|
+
MY_SECRET=TEST
|
|
145
|
+
APP_CLIENT_ID=${NON_EXISTING_ENV:-DEFAULT_ID} // --> APP_CLIENT_ID=DEFAULT_ID
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Dealing with Secrets
|
|
149
|
+
|
|
150
|
+
Out of the box, this module can resolve AWS Secrets Manager and Parameter Store secrets.
|
|
151
|
+
|
|
152
|
+
Every configuration attribute stating with `AWS_SECRETS_MANAGER`, `AWS_PARAMETER_STORE`, `aws-secrets-manager` and `aws-parameter-store` will be considered a special configuration attribute and the module will try to resolve it's remote value.
|
|
153
|
+
|
|
154
|
+
E.g.: `.env`
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
MY_DB_PASSWORD=${AWS_SECRETS_MANAGER_DB_PASSWORD}
|
|
158
|
+
MY_API_TOKEN=${AWS_PARAMETER_STORE_API_TOKEN}
|
|
159
|
+
|
|
160
|
+
AWS_SECRETS_MANAGER_DB_PASSWORD=<secret-id-here>
|
|
161
|
+
AWS_PARAMETER_STORE_API_TOKEN=<parameter-name-here>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`application.yml`
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
my-db-password: ${aws-secrets-manager.db.password}
|
|
168
|
+
my-api-token: ${aws-parameter-store.api.token}
|
|
169
|
+
|
|
170
|
+
aws-secrets-manager:
|
|
171
|
+
db:
|
|
172
|
+
password: <secret-id-here>
|
|
173
|
+
|
|
174
|
+
aws-parameter-store:
|
|
175
|
+
api:
|
|
176
|
+
token: <parameter-name-here>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
@Configuration()
|
|
181
|
+
export class SecretConfiguration {
|
|
182
|
+
@Value('my-db-password') // or @Value('aws-secrets-manager.db.password')
|
|
183
|
+
myDbPassword: string;
|
|
184
|
+
|
|
185
|
+
@Value('my-api-token') // or @Value('aws-parameter-store.api.token')
|
|
186
|
+
myApiToken: string;
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Parsing Configuration Values
|
|
191
|
+
|
|
192
|
+
Parsing a configuration value can be easily done by using a parse callback function available as argument of the `@Value()` decorator:
|
|
193
|
+
|
|
194
|
+
```yaml
|
|
195
|
+
db-json-config: |
|
|
196
|
+
{
|
|
197
|
+
"host": "localhost",
|
|
198
|
+
"user": "test",
|
|
199
|
+
"password": "test"
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
export interface MyDBConfig {
|
|
205
|
+
host: string;
|
|
206
|
+
user: string;
|
|
207
|
+
password: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@Configuration()
|
|
211
|
+
export class SuperSecretConfiguration {
|
|
212
|
+
@Value('db-json-config', {
|
|
213
|
+
parse: (value: any) => JSON.parse(value)
|
|
214
|
+
})
|
|
215
|
+
myDbConfig: MyDBConfig;
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Validating Configuration Classes
|
|
220
|
+
|
|
221
|
+
Depending on how critical a configuration is, you may want to validate it before bootstraping the application, for that you can use [class-validator](https://github.com/typestack/class-validator) to make sure your configuration is loaded correctly:
|
|
222
|
+
|
|
223
|
+
```js
|
|
224
|
+
@Configuration()
|
|
225
|
+
export class MyConfiguration {
|
|
226
|
+
@IsEmail()
|
|
227
|
+
@Value('SENDER_EMAIL')
|
|
228
|
+
senderEmail: string;
|
|
229
|
+
|
|
230
|
+
@IsNotEmpty()
|
|
231
|
+
@Value('my-api-token')
|
|
232
|
+
myApiToken: string;
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Overwrite Default Options
|
|
237
|
+
|
|
238
|
+
You can overwrite default module otions by providing an object as argumento to the `forRootAsync()` method:
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
/**
|
|
242
|
+
* Ignores any config file.
|
|
243
|
+
* The default value is false;
|
|
244
|
+
*/
|
|
245
|
+
ignoreConfigFile?: boolean;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Ignores environment variables
|
|
249
|
+
* The default value is false;
|
|
250
|
+
*/
|
|
251
|
+
ignoreEnvVars?: boolean;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The path of the configuration files
|
|
255
|
+
*/
|
|
256
|
+
configFilePath?: string | string[];
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Expands variables
|
|
260
|
+
* The default value is true
|
|
261
|
+
*/
|
|
262
|
+
expandConfig?: boolean;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The AWS Secrets Manager Client
|
|
266
|
+
* If no client is provided, the module will create one.
|
|
267
|
+
*/
|
|
268
|
+
secretsManagerClient?: SecretsManagerClient;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The AWS Systems Manager Client
|
|
272
|
+
* If no client is provided, the module will create one.
|
|
273
|
+
*/
|
|
274
|
+
ssmClient?: SSMClient;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
This code is licensed under the [MIT License](./LICENSE.txt).
|
|
280
|
+
|
|
281
|
+
All files located in the node_modules and external directories are externally maintained libraries used by this software which have their own licenses; we recommend you read them, as their terms may differ from the terms in the MIT License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { ConfigfyModuleOptions } from './configuration';
|
|
3
|
+
export declare class ConfigifyModule {
|
|
4
|
+
private static readonly DEFAULT_CONFIG_FILES;
|
|
5
|
+
private static readonly SECRETS_RESOLVER_PIPELINE;
|
|
6
|
+
static forRootAsync(options?: ConfigfyModuleOptions): Promise<DynamicModule>;
|
|
7
|
+
private static runSecretsResolverPipeline;
|
|
8
|
+
private static buildConfigurationProviders;
|
|
9
|
+
private static flattenObjectKeys;
|
|
10
|
+
private static parseConfigurationFiles;
|
|
11
|
+
private static resolveConfigurationFiles;
|
|
12
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var ConfigifyModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ConfigifyModule = void 0;
|
|
11
|
+
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
12
|
+
const client_ssm_1 = require("@aws-sdk/client-ssm");
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const configuration_1 = require("./configuration");
|
|
18
|
+
const parameter_store_configuration_resolver_1 = require("./configuration/resolvers/aws/parameter-store-configuration.resolver");
|
|
19
|
+
const variables_1 = require("./interpolation/variables");
|
|
20
|
+
let ConfigifyModule = ConfigifyModule_1 = class ConfigifyModule {
|
|
21
|
+
static async forRootAsync(options = {}) {
|
|
22
|
+
const settings = Object.assign(Object.assign({}, options), configuration_1.DefaultConfigfyModuleOptions);
|
|
23
|
+
const files = this.resolveConfigurationFiles(settings.configFilePath);
|
|
24
|
+
const envVars = settings.ignoreEnvVars ? {} : process.env;
|
|
25
|
+
const fromFile = settings.ignoreConfigFile
|
|
26
|
+
? {}
|
|
27
|
+
: this.parseConfigurationFiles(files);
|
|
28
|
+
const container = Object.assign(Object.assign({}, envVars), fromFile);
|
|
29
|
+
const secrets = await this.runSecretsResolverPipeline(container, settings);
|
|
30
|
+
const configuration = Object.assign(Object.assign({}, container), secrets);
|
|
31
|
+
if (settings.expandConfig) {
|
|
32
|
+
const expanded = variables_1.Variables.expand(configuration);
|
|
33
|
+
Object.assign(configuration, expanded);
|
|
34
|
+
}
|
|
35
|
+
Object.assign(process.env, configuration);
|
|
36
|
+
const { exports, providers } = this.buildConfigurationProviders();
|
|
37
|
+
return {
|
|
38
|
+
exports,
|
|
39
|
+
providers,
|
|
40
|
+
global: true,
|
|
41
|
+
module: ConfigifyModule_1,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
static async runSecretsResolverPipeline(config, options) {
|
|
45
|
+
const secrets = {};
|
|
46
|
+
for (const buildResolver of this.SECRETS_RESOLVER_PIPELINE) {
|
|
47
|
+
const resolver = buildResolver(options);
|
|
48
|
+
const result = await resolver.resolve(config);
|
|
49
|
+
Object.assign(secrets, result);
|
|
50
|
+
}
|
|
51
|
+
return secrets;
|
|
52
|
+
}
|
|
53
|
+
static buildConfigurationProviders() {
|
|
54
|
+
var _a;
|
|
55
|
+
const exports = [];
|
|
56
|
+
const providers = [];
|
|
57
|
+
const registry = configuration_1.ConfigurationRegistry.getRegistry();
|
|
58
|
+
for (const ConfigType of registry) {
|
|
59
|
+
const instance = new ConfigType();
|
|
60
|
+
const attributes = configuration_1.ConfigurationRegistry.getValueDecoratedAttributes(instance);
|
|
61
|
+
for (const attribute of attributes) {
|
|
62
|
+
const metadata = configuration_1.ConfigurationRegistry.getValueDecoratedKey(instance, attribute);
|
|
63
|
+
const parse = (_a = metadata.options) === null || _a === void 0 ? void 0 : _a.parse;
|
|
64
|
+
const value = parse
|
|
65
|
+
? parse(process.env[metadata.key])
|
|
66
|
+
: process.env[metadata.key];
|
|
67
|
+
instance[attribute] = value;
|
|
68
|
+
}
|
|
69
|
+
const errors = (0, class_validator_1.validateSync)(instance);
|
|
70
|
+
if (errors && errors.length) {
|
|
71
|
+
throw new Error(`validation constraints violated:\n${errors
|
|
72
|
+
.map((e) => JSON.stringify({ attribute: e.property, constraints: e.constraints }, null, 2))
|
|
73
|
+
.join('\n')}`);
|
|
74
|
+
}
|
|
75
|
+
exports.push(ConfigType);
|
|
76
|
+
providers.push({ provide: ConfigType, useValue: instance });
|
|
77
|
+
}
|
|
78
|
+
return { exports, providers };
|
|
79
|
+
}
|
|
80
|
+
static flattenObjectKeys(source, path = [], target = {}) {
|
|
81
|
+
if (typeof source === 'object') {
|
|
82
|
+
for (const key in source) {
|
|
83
|
+
this.flattenObjectKeys(source[key], [...path, key], target);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
target[path.join('.')] = source;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
static parseConfigurationFiles(files) {
|
|
91
|
+
const kv = {};
|
|
92
|
+
const config = {};
|
|
93
|
+
for (const file of files) {
|
|
94
|
+
const parser = configuration_1.ConfigurationParserFactory.getParser(file);
|
|
95
|
+
const parsed = parser.parse(file);
|
|
96
|
+
Object.assign(config, parsed);
|
|
97
|
+
}
|
|
98
|
+
this.flattenObjectKeys(config, [], kv);
|
|
99
|
+
return kv;
|
|
100
|
+
}
|
|
101
|
+
static resolveConfigurationFiles(path) {
|
|
102
|
+
return []
|
|
103
|
+
.concat(path, this.DEFAULT_CONFIG_FILES)
|
|
104
|
+
.filter((file) => fs.existsSync(file) && configuration_1.ConfigurationParserFactory.supports(file));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.ConfigifyModule = ConfigifyModule;
|
|
108
|
+
ConfigifyModule.DEFAULT_CONFIG_FILES = [
|
|
109
|
+
(0, path_1.resolve)(process.cwd(), '.env'),
|
|
110
|
+
(0, path_1.resolve)(process.cwd(), 'application.yml'),
|
|
111
|
+
(0, path_1.resolve)(process.cwd(), 'application.json'),
|
|
112
|
+
];
|
|
113
|
+
ConfigifyModule.SECRETS_RESOLVER_PIPELINE = [
|
|
114
|
+
(options) => new configuration_1.AwsSecretsManagerConfigurationResolver(options.secretsManagerClient || new client_secrets_manager_1.SecretsManagerClient()),
|
|
115
|
+
(options) => new parameter_store_configuration_resolver_1.AwsParameterStoreConfigurationResolver(options.ssmClient || new client_ssm_1.SSMClient()),
|
|
116
|
+
];
|
|
117
|
+
exports.ConfigifyModule = ConfigifyModule = ConfigifyModule_1 = __decorate([
|
|
118
|
+
(0, common_1.Module)({})
|
|
119
|
+
], ConfigifyModule);
|
|
120
|
+
//# sourceMappingURL=configify.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configify.module.js","sourceRoot":"","sources":["../../src/configify.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,4EAAuE;AACvE,oDAAgD;AAChD,2CAAiE;AACjE,qDAA+C;AAC/C,yBAAyB;AACzB,+BAA+B;AAC/B,mDAOyB;AACzB,iIAA8H;AAC9H,yDAAsD;AAmB/C,IAAM,eAAe,uBAArB,MAAM,eAAe;IA0C1B,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,UAAiC,EAAE;QAEnC,MAAM,QAAQ,mCAAQ,OAAO,GAAK,4CAA4B,CAAE,CAAC;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAEtE,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;QAC1D,MAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB;YACxC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAExC,MAAM,SAAS,mCAAQ,OAAO,GAAK,QAAQ,CAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC3E,MAAM,aAAa,mCAAQ,SAAS,GAAK,OAAO,CAAE,CAAC;QAEnD,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,qBAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,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A8B,EAAE,EAAE,CACjC,IAAI,+EAAsC,CACxC,OAAO,CAAC,SAAS,IAAI,IAAI,sBAAS,EAAE,CACrC;CACJ,AAVgD,CAU/C;0BA5BS,eAAe;IAD3B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CA8M3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
|
|
2
|
+
import { SSMClient } from '@aws-sdk/client-ssm';
|
|
3
|
+
export interface ConfigfyModuleOptions {
|
|
4
|
+
ignoreConfigFile?: boolean;
|
|
5
|
+
ignoreEnvVars?: boolean;
|
|
6
|
+
configFilePath?: string | string[];
|
|
7
|
+
expandConfig?: boolean;
|
|
8
|
+
secretsManagerClient?: SecretsManagerClient;
|
|
9
|
+
ssmClient?: SSMClient;
|
|
10
|
+
}
|
|
11
|
+
export declare const DefaultConfigfyModuleOptions: ConfigfyModuleOptions;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultConfigfyModuleOptions = void 0;
|
|
4
|
+
exports.DefaultConfigfyModuleOptions = {
|
|
5
|
+
ignoreConfigFile: false,
|
|
6
|
+
ignoreEnvVars: false,
|
|
7
|
+
expandConfig: true,
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=configuration-options.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-options.interface.js","sourceRoot":"","sources":["../../../src/configuration/configuration-options.interface.ts"],"names":[],"mappings":";;;AA8Ca,QAAA,4BAA4B,GAA0B;IACjE,gBAAgB,EAAE,KAAK;IACvB,aAAa,EAAE,KAAK;IACpB,YAAY,EAAE,IAAI;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-parser.interface.js","sourceRoot":"","sources":["../../../src/configuration/configuration-parser.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-providers.interface.js","sourceRoot":"","sources":["../../../src/configuration/configuration-providers.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValueDecoratedKey } from '../decorators';
|
|
2
|
+
export declare class ConfigurationRegistry {
|
|
3
|
+
private static readonly registry;
|
|
4
|
+
static registerTarget(type: any): void;
|
|
5
|
+
static registerAttribute(target: any, attribute: string): void;
|
|
6
|
+
static getRegistry(): any[];
|
|
7
|
+
static getValueDecoratedAttributes(target: any): string[];
|
|
8
|
+
static getValueDecoratedKey(instance: any, attribute: string): ValueDecoratedKey;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigurationRegistry = void 0;
|
|
4
|
+
const decorators_1 = require("../decorators");
|
|
5
|
+
class ConfigurationRegistry {
|
|
6
|
+
static registerTarget(type) {
|
|
7
|
+
this.registry.push(type);
|
|
8
|
+
}
|
|
9
|
+
static registerAttribute(target, attribute) {
|
|
10
|
+
(target[decorators_1.VALUE_PROPERTIES_METADATA] ||
|
|
11
|
+
(target[decorators_1.VALUE_PROPERTIES_METADATA] = [])).push(attribute);
|
|
12
|
+
}
|
|
13
|
+
static getRegistry() {
|
|
14
|
+
return this.registry;
|
|
15
|
+
}
|
|
16
|
+
static getValueDecoratedAttributes(target) {
|
|
17
|
+
return target[decorators_1.VALUE_PROPERTIES_METADATA];
|
|
18
|
+
}
|
|
19
|
+
static getValueDecoratedKey(instance, attribute) {
|
|
20
|
+
return Reflect.getMetadata(decorators_1.VALUE_METADATA, instance, attribute);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ConfigurationRegistry = ConfigurationRegistry;
|
|
24
|
+
ConfigurationRegistry.registry = [];
|
|
25
|
+
//# sourceMappingURL=configuration.registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.registry.js","sourceRoot":"","sources":["../../../src/configuration/configuration.registry.ts"],"names":[],"mappings":";;;AAAA,8CAIuB;AAQvB,MAAa,qBAAqB;IAQhC,MAAM,CAAC,cAAc,CAAC,IAAS;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAQD,MAAM,CAAC,iBAAiB,CAAC,MAAW,EAAE,SAAiB;QACrD,CACE,MAAM,CAAC,sCAAyB,CAAC;YACjC,CAAC,MAAM,CAAC,sCAAyB,CAAC,GAAG,EAAE,CAAC,CACzC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpB,CAAC;IAOD,MAAM,CAAC,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAQD,MAAM,CAAC,2BAA2B,CAAC,MAAW;QAC5C,OAAO,MAAM,CAAC,sCAAyB,CAAC,CAAC;IAC3C,CAAC;IASD,MAAM,CAAC,oBAAoB,CACzB,QAAa,EACb,SAAiB;QAEjB,OAAO,OAAO,CAAC,WAAW,CAAC,2BAAc,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;;AAxDH,sDAyDC;AAxDyB,8BAAQ,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./configuration-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./configuration-parser.interface"), exports);
|
|
19
|
+
__exportStar(require("./configuration-providers.interface"), exports);
|
|
20
|
+
__exportStar(require("./configuration.registry"), exports);
|
|
21
|
+
__exportStar(require("./parsers"), exports);
|
|
22
|
+
__exportStar(require("./resolvers"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAkD;AAClD,mEAAiD;AACjD,sEAAoD;AACpD,2DAAyC;AACzC,4CAA0B;AAC1B,8CAA4B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigurationParser } from '../configuration-parser.interface';
|
|
2
|
+
export declare class ConfigurationParserFactory {
|
|
3
|
+
private static readonly parsers;
|
|
4
|
+
static getParser(file: string): ConfigurationParser;
|
|
5
|
+
static supports(file: string): boolean;
|
|
6
|
+
private static getFileExt;
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigurationParserFactory = void 0;
|
|
4
|
+
const dotenv_configuration_parser_1 = require("./dotenv-configuration.parser");
|
|
5
|
+
const json_configuration_parser_1 = require("./json-configuration.parser");
|
|
6
|
+
const yaml_configuration_parser_1 = require("./yaml-configuration.parser");
|
|
7
|
+
class ConfigurationParserFactory {
|
|
8
|
+
static getParser(file) {
|
|
9
|
+
const ext = this.getFileExt(file);
|
|
10
|
+
return this.parsers[ext];
|
|
11
|
+
}
|
|
12
|
+
static supports(file) {
|
|
13
|
+
const ext = this.getFileExt(file);
|
|
14
|
+
return this.parsers.hasOwnProperty(ext);
|
|
15
|
+
}
|
|
16
|
+
static getFileExt(file) {
|
|
17
|
+
return file.split('.').pop();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ConfigurationParserFactory = ConfigurationParserFactory;
|
|
21
|
+
ConfigurationParserFactory.parsers = {
|
|
22
|
+
env: new dotenv_configuration_parser_1.DotEnvConfigurationParser(),
|
|
23
|
+
yml: new yaml_configuration_parser_1.YamlConfigurationParser(),
|
|
24
|
+
yaml: new yaml_configuration_parser_1.YamlConfigurationParser(),
|
|
25
|
+
json: new json_configuration_parser_1.JsonConfigurationParser(),
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=configuration-parser.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration-parser.factory.js","sourceRoot":"","sources":["../../../../src/configuration/parsers/configuration-parser.factory.ts"],"names":[],"mappings":";;;AACA,+EAA0E;AAC1E,2EAAsE;AACtE,2EAAsE;AAOtE,MAAa,0BAA0B;IAiBrC,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAQD,MAAM,CAAC,QAAQ,CAAC,IAAY;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IAQO,MAAM,CAAC,UAAU,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC/B,CAAC;;AAzCH,gEA0CC;AAtCyB,kCAAO,GAAG;IAChC,GAAG,EAAE,IAAI,uDAAyB,EAAE;IACpC,GAAG,EAAE,IAAI,mDAAuB,EAAE;IAClC,IAAI,EAAE,IAAI,mDAAuB,EAAE;IACnC,IAAI,EAAE,IAAI,mDAAuB,EAAE;CACpC,CAAC"}
|