1- # Preference Injector
1+ = Preference Injector
22
33A powerful, type-safe preference injection system for dynamic configuration management in Node.js and TypeScript applications.
44
5- ## Features
5+ == Features
66
7- - ** Multiple Providers* * : File-based, environment variables, API, and in-memory storage
8- - ** Priority System* * : Resolve conflicts between providers using customizable strategies
9- - ** Type Safety* * : Full TypeScript support with generic type helpers
10- - ** Caching* * : LRU and TTL caching strategies for performance
11- - ** Validation* * : Schema-based and custom validation rules
12- - ** Encryption* * : AES-256-GCM encryption for sensitive preferences
13- - ** Audit Logging* * : Track all preference operations
14- - ** Migrations* * : Version and migrate preference schemas
15- - ** React Integration* * : Hooks and context providers
16- - ** Express Middleware* * : RESTful API and request helpers
17- - ** CLI Tool* * : Command-line interface for preference management
7+ - *Multiple Providers*: File-based, environment variables, API, and in-memory storage
8+ - *Priority System*: Resolve conflicts between providers using customizable strategies
9+ - *Type Safety*: Full TypeScript support with generic type helpers
10+ - *Caching*: LRU and TTL caching strategies for performance
11+ - *Validation*: Schema-based and custom validation rules
12+ - *Encryption*: AES-256-GCM encryption for sensitive preferences
13+ - *Audit Logging*: Track all preference operations
14+ - *Migrations*: Version and migrate preference schemas
15+ - *React Integration*: Hooks and context providers
16+ - *Express Middleware*: RESTful API and request helpers
17+ - *CLI Tool*: Command-line interface for preference management
1818
19- ## Installation
19+ == Installation
2020
2121```bash
2222npm install @hyperpolymath/preference-injector
2323```
2424
25- ## Quick Start
25+ == Quick Start
2626
2727```typescript
2828import { PreferenceInjector, MemoryProvider } from '@hyperpolymath/preference-injector';
@@ -47,9 +47,9 @@ const fontSize = await injector.getTyped<number>('fontSize');
4747console.log('Font Size:', fontSize); // 14
4848```
4949
50- ## Providers
50+ == Providers
5151
52- ### Memory Provider
52+ === Memory Provider
5353
5454In-memory storage for runtime preferences:
5555
@@ -59,7 +59,7 @@ import { MemoryProvider, PreferencePriority } from '@hyperpolymath/preference-in
5959const provider = new MemoryProvider(PreferencePriority.NORMAL);
6060```
6161
62- ### File Provider
62+ === File Provider
6363
6464JSON or .env file-based storage:
6565
@@ -74,7 +74,7 @@ const provider = new FileProvider({
7474});
7575```
7676
77- ### Environment Provider
77+ === Environment Provider
7878
7979Environment variable integration:
8080
@@ -88,7 +88,7 @@ const provider = new EnvProvider({
8888});
8989```
9090
91- ### API Provider
91+ === API Provider
9292
9393Remote configuration service:
9494
@@ -104,7 +104,7 @@ const provider = new ApiProvider({
104104});
105105```
106106
107- ## Multi-Provider Setup
107+ == Multi-Provider Setup
108108
109109Use multiple providers with automatic conflict resolution:
110110
@@ -119,7 +119,7 @@ const injector = new PreferenceInjector({
119119});
120120```
121121
122- ## Validation
122+ == Validation
123123
124124Add validation rules to ensure preference values are valid:
125125
@@ -137,7 +137,7 @@ validator.addRule('username', CommonValidationRules.stringLength(3, 20));
137137await injector.set('email', 'user@example.com', { validate: true });
138138```
139139
140- ## Schema Validation
140+ == Schema Validation
141141
142142Define schemas for your preferences:
143143
@@ -153,7 +153,7 @@ const schema = new SchemaBuilder()
153153const schemaValidator = new SchemaValidator(schema);
154154```
155155
156- ## Encryption
156+ == Encryption
157157
158158Encrypt sensitive preferences:
159159
@@ -170,7 +170,7 @@ await injector.set('apiKey', 'secret-key', { encrypt: true });
170170const apiKey = await injector.get('apiKey', { decrypt: true });
171171```
172172
173- ## Caching
173+ == Caching
174174
175175Enable caching for better performance:
176176
@@ -182,7 +182,7 @@ const injector = new PreferenceInjector({
182182});
183183```
184184
185- ## Audit Logging
185+ == Audit Logging
186186
187187Track all preference operations:
188188
@@ -197,7 +197,7 @@ const auditLogger = injector.getAuditLogger();
197197const entries = auditLogger.getEntries();
198198```
199199
200- ## React Integration
200+ == React Integration
201201
202202Use preferences in React applications:
203203
@@ -225,7 +225,7 @@ function ThemeToggle() {
225225}
226226```
227227
228- ## Express Integration
228+ == Express Integration
229229
230230Add preference management to Express applications:
231231
@@ -251,28 +251,28 @@ app.get('/config', async (req, res) => {
251251});
252252```
253253
254- ## CLI Tool
254+ == CLI Tool
255255
256256Manage preferences from the command line:
257257
258258```bash
259- # Get a preference
259+ = Get a preference
260260preference-injector get theme
261261
262- # Set a preference
262+ = Set a preference
263263preference-injector set theme dark
264264
265- # List all preferences
265+ = List all preferences
266266preference-injector -f config.json list
267267
268- # Delete a preference
268+ = Delete a preference
269269preference-injector delete old-key
270270
271- # Clear all preferences
271+ = Clear all preferences
272272preference-injector clear
273273```
274274
275- ## Migrations
275+ == Migrations
276276
277277Version and migrate preference schemas:
278278
@@ -299,26 +299,26 @@ manager.register(
299299await manager.migrateToLatest(preferences, 0);
300300```
301301
302- ## API Documentation
302+ == API Documentation
303303
304304For detailed API documentation, see [API.md](./docs/API.md).
305305
306- ## Examples
306+ == Examples
307307
308308Check the [examples](./examples) directory for more usage examples:
309309
310310- [Basic Usage](./examples/basic-usage.ts)
311311- [React Integration](./examples/react-example.tsx)
312312- [Express Integration](./examples/express-example.ts)
313313
314- ## Contributing
314+ == Contributing
315315
316316Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
317317
318- ## License
318+ == License
319319
320320MIT
321321
322- ## Changelog
322+ == Changelog
323323
324324See [CHANGELOG.md](./CHANGELOG.md) for release history.
0 commit comments