@grest-ts/config 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Grest Games OÜ
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Grest Games OÜ
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 CHANGED
@@ -3,60 +3,60 @@
3
3
  > [Documentation](https://github.com/grest-ts/grest-ts#readme) | [All packages](https://github.com/grest-ts/grest-ts#package-reference)
4
4
  <!-- GREST-TS-BANNER-END -->
5
5
 
6
- # @grest-ts/config
7
-
8
- Type-safe configuration management for Grest Framework.
9
-
10
- ## Features
11
-
12
- - Type-safe configuration keys with validation
13
- - Multiple key types (Settings, Secrets, Resources)
14
- - Pluggable storage backends (file, environment, remote)
15
- - Runtime configuration updates with watchers
16
- - Centralized configuration definitions
17
- - Config values are validated!
18
-
19
- ## Pattern
20
-
21
- - Keys are defined statically, but values are resolved at runtime from async context
22
- - Different key types (Setting, Secret, Resource) can use different storage backends (Strategy pattern)
23
- - Supports watching for runtime configuration changes (Observer pattern)
24
-
25
- ## Quick usage example
26
-
27
- ```typescript
28
- import {GGConfig, GGResource, GGSecret, GGSetting} from "@grest-ts/config"
29
-
30
- // Define configuration keys
31
- export const AppConfig = GGConfig.define('/app/', () => ({
32
- port: new GGSetting('port', 3000, 'Server port', IsInt),
33
- apiKey: new GGSecret('apiKey', '', 'External API key', IsString),
34
- dbUrl: new GGResource('db/url', 'localhost:5432', 'Database URL', IsString)
35
- }));
36
-
37
- // Usage in runtime
38
- const port = AppConfig.port.get();
39
- const apiKey = AppConfig.apiKey.reveal();
40
- const dbUrl = AppConfig.dbUrl.get(); // if value changes, you get the new value
41
-
42
- // Watch for changes (in case you need to) - as a simple example: you need to roll a mysql user password and start a new pool without any downtime.
43
- AppConfig.dbUrl.watch(() => {
44
- // Do something when dbUrl changes
45
- })
46
-
47
- // Where actually values come from? You define the source in the runtime compose.
48
- // in example we use a file (don't really use files, use proper services for each category!)
49
- // These particular stores also watch the file for updates. Most stores should allow dynamic config updates!
50
- // You can also add your own stores, groups etc rather easily.
51
- new GGConfigLoader(new Map<any, any>([
52
- [GGSetting, new GGConfigStoreFile("./config/settings.json", import.meta.url)],
53
- [GGSecret, new GGConfigStoreFile("./config/secrets.json", import.meta.url)],
54
- [GGResource, new GGConfigStoreFile("./config/resources.json", import.meta.url)]
55
- ]));
56
-
57
- ```
58
-
59
- ## Documentation
60
-
61
- - [Usage](./README-usage.md) - How to define and use configuration
62
- - [Extending](./README-extending.md) - How to add custom key types and stores
6
+ # @grest-ts/config
7
+
8
+ Type-safe configuration management for Grest Framework.
9
+
10
+ ## Features
11
+
12
+ - Type-safe configuration keys with validation
13
+ - Multiple key types (Settings, Secrets, Resources)
14
+ - Pluggable storage backends (file, environment, remote)
15
+ - Runtime configuration updates with watchers
16
+ - Centralized configuration definitions
17
+ - Config values are validated!
18
+
19
+ ## Pattern
20
+
21
+ - Keys are defined statically, but values are resolved at runtime from async context
22
+ - Different key types (Setting, Secret, Resource) can use different storage backends (Strategy pattern)
23
+ - Supports watching for runtime configuration changes (Observer pattern)
24
+
25
+ ## Quick usage example
26
+
27
+ ```typescript
28
+ import {GGConfig, GGResource, GGSecret, GGSetting} from "@grest-ts/config"
29
+
30
+ // Define configuration keys
31
+ export const AppConfig = GGConfig.define('/app/', () => ({
32
+ port: new GGSetting('port', 3000, 'Server port', IsInt),
33
+ apiKey: new GGSecret('apiKey', '', 'External API key', IsString),
34
+ dbUrl: new GGResource('db/url', 'localhost:5432', 'Database URL', IsString)
35
+ }));
36
+
37
+ // Usage in runtime
38
+ const port = AppConfig.port.get();
39
+ const apiKey = AppConfig.apiKey.reveal();
40
+ const dbUrl = AppConfig.dbUrl.get(); // if value changes, you get the new value
41
+
42
+ // Watch for changes (in case you need to) - as a simple example: you need to roll a mysql user password and start a new pool without any downtime.
43
+ AppConfig.dbUrl.watch(() => {
44
+ // Do something when dbUrl changes
45
+ })
46
+
47
+ // Where actually values come from? You define the source in the runtime compose.
48
+ // in example we use a file (don't really use files, use proper services for each category!)
49
+ // These particular stores also watch the file for updates. Most stores should allow dynamic config updates!
50
+ // You can also add your own stores, groups etc rather easily.
51
+ new GGConfigLoader(new Map<any, any>([
52
+ [GGSetting, new GGConfigStoreFile("./config/settings.json", import.meta.url)],
53
+ [GGSecret, new GGConfigStoreFile("./config/secrets.json", import.meta.url)],
54
+ [GGResource, new GGConfigStoreFile("./config/resources.json", import.meta.url)]
55
+ ]));
56
+
57
+ ```
58
+
59
+ ## Documentation
60
+
61
+ - [Usage](./README-usage.md) - How to define and use configuration
62
+ - [Extending](./README-extending.md) - How to add custom key types and stores