@keshavsoft/kschema 1.0.0 → 1.0.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 +74 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @keshavsoft/kschema
|
|
2
|
+
|
|
3
|
+
A minimal config store for loading and accessing JSON configuration across your application.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @keshavsoft/kschema
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 📦 Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { loadConfig, getConfig } from "@keshavsoft/kschema";
|
|
19
|
+
|
|
20
|
+
loadConfig({ name: "test" });
|
|
21
|
+
|
|
22
|
+
console.log(getConfig());
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🧠 API
|
|
28
|
+
|
|
29
|
+
### loadConfig(config)
|
|
30
|
+
|
|
31
|
+
Loads the configuration into memory.
|
|
32
|
+
|
|
33
|
+
* `config` → Object
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### getConfig()
|
|
38
|
+
|
|
39
|
+
Returns the loaded configuration.
|
|
40
|
+
|
|
41
|
+
* Throws error if config is not loaded
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ⚠️ Notes
|
|
46
|
+
|
|
47
|
+
* Config is stored in-memory
|
|
48
|
+
* Must call `loadConfig` before `getConfig`
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 📌 Example
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
loadConfig({ user: "keshav" });
|
|
56
|
+
|
|
57
|
+
const data = getConfig();
|
|
58
|
+
|
|
59
|
+
console.log(data.user); // keshav
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🛠 Future Scope
|
|
65
|
+
|
|
66
|
+
* Validation support
|
|
67
|
+
* Config updates
|
|
68
|
+
* Remote config loading
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 👨💻 Author
|
|
73
|
+
|
|
74
|
+
KeshavSoft
|