@maroonedsoftware/appconfig 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -27,11 +27,12 @@ import { AppConfig } from '@maroonedsoftware/appconfig';
|
|
|
27
27
|
const config = new AppConfig({
|
|
28
28
|
database: { host: 'localhost', port: 5432 },
|
|
29
29
|
api: { timeout: 5000 },
|
|
30
|
+
port: '3000',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
const
|
|
33
|
-
const port = config.getNumber('port');
|
|
34
|
-
const db = config.getAs<{ host: string }>('database');
|
|
33
|
+
const database = config.get('database'); // Type-safe access
|
|
34
|
+
const port = config.getNumber('port'); // Returns 3000 as number
|
|
35
|
+
const db = config.getAs<{ host: string }>('database'); // Cast to interface
|
|
35
36
|
```
|
|
36
37
|
|
|
37
38
|
### Using the Builder
|
|
@@ -309,10 +310,10 @@ const provider = new AppConfigProviderGcpSecrets('my-project-id');
|
|
|
309
310
|
const provider = new AppConfigProviderGcpSecrets('my-project-id', /\$\{secret:([^}]+)\}/g);
|
|
310
311
|
```
|
|
311
312
|
|
|
312
|
-
| Parameter | Type | Description
|
|
313
|
-
| ----------- | ------------------ |
|
|
314
|
-
| `projectId` | `string` | The GCP project ID where secrets are stored
|
|
315
|
-
| `prefix` | `string \| RegExp` | Optional
|
|
313
|
+
| Parameter | Type | Description |
|
|
314
|
+
| ----------- | ------------------ | -------------------------------------------------------------------------------------------- |
|
|
315
|
+
| `projectId` | `string` | The GCP project ID where secrets are stored |
|
|
316
|
+
| `prefix` | `string \| RegExp` | Optional pattern to match secret references. Default: `/\$\{gcp:(.+)\}/g` (matches `${gcp:NAME}`) |
|
|
316
317
|
|
|
317
318
|
The provider:
|
|
318
319
|
|
|
@@ -369,20 +370,22 @@ class MyCustomSource implements AppConfigSource {
|
|
|
369
370
|
### Creating a Custom Provider
|
|
370
371
|
|
|
371
372
|
```typescript
|
|
372
|
-
import { AppConfigProvider
|
|
373
|
+
import { AppConfigProvider } from '@maroonedsoftware/appconfig';
|
|
373
374
|
|
|
374
375
|
class MyCustomProvider implements AppConfigProvider {
|
|
375
376
|
canParse(value: string): boolean {
|
|
376
377
|
return value.startsWith('custom:');
|
|
377
378
|
}
|
|
378
379
|
|
|
379
|
-
async parse(value: string, meta
|
|
380
|
+
async parse(value: string, meta): Promise<void> {
|
|
380
381
|
const transformed = value.replace('custom:', '');
|
|
381
382
|
(meta.owner as Record<string, unknown>)[meta.propertyPath] = transformed;
|
|
382
383
|
}
|
|
383
384
|
}
|
|
384
385
|
```
|
|
385
386
|
|
|
387
|
+
The `meta` parameter is an `ObjectVisitorMeta` describing where the value lives in the configuration object (`owner`, `propertyPath`, `arrayIndex`, etc.). Mutate `meta.owner[meta.propertyPath]` (or `meta.owner[meta.arrayIndex]` for array entries) to write the transformed value back.
|
|
388
|
+
|
|
386
389
|
## Configuration Merging
|
|
387
390
|
|
|
388
391
|
When using multiple sources, configurations are deep-merged in the order they are added. Later sources override earlier ones:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maroonedsoftware/appconfig",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "A flexible, type-safe configuration management library with support for multiple sources and value transformation.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marooned Software",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"deepmerge-ts": "^7.1.5",
|
|
34
|
-
"dotenv": "^17.
|
|
35
|
-
"injectkit": "^1.
|
|
34
|
+
"dotenv": "^17.4.2",
|
|
35
|
+
"injectkit": "^1.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@google-cloud/secret-manager": "^6.1.
|
|
39
|
-
"yaml": "^2.8.
|
|
40
|
-
"@repo/config-eslint": "0.2.
|
|
38
|
+
"@google-cloud/secret-manager": "^6.1.2",
|
|
39
|
+
"yaml": "^2.8.4",
|
|
40
|
+
"@repo/config-eslint": "0.2.1",
|
|
41
41
|
"@repo/config-typescript": "0.1.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|