@wgtechlabs/nuvex 0.1.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/LICENSE +21 -0
- package/README.md +427 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/cjs/core/client.js +981 -0
- package/dist/cjs/core/client.js.map +1 -0
- package/dist/cjs/core/database.js +297 -0
- package/dist/cjs/core/database.js.map +1 -0
- package/dist/cjs/core/engine.js +1202 -0
- package/dist/cjs/core/engine.js.map +1 -0
- package/dist/cjs/core/index.js +35 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/index.js +109 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/index.js +12 -0
- package/dist/cjs/interfaces/index.js.map +1 -0
- package/dist/cjs/layers/index.js +22 -0
- package/dist/cjs/layers/index.js.map +1 -0
- package/dist/cjs/layers/memory.js +388 -0
- package/dist/cjs/layers/memory.js.map +1 -0
- package/dist/cjs/layers/postgres.js +492 -0
- package/dist/cjs/layers/postgres.js.map +1 -0
- package/dist/cjs/layers/redis.js +388 -0
- package/dist/cjs/layers/redis.js.map +1 -0
- package/dist/cjs/types/index.js +52 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/esm/core/client.js +944 -0
- package/dist/esm/core/client.js.map +1 -0
- package/dist/esm/core/database.js +289 -0
- package/dist/esm/core/database.js.map +1 -0
- package/dist/esm/core/engine.js +1198 -0
- package/dist/esm/core/engine.js.map +1 -0
- package/dist/esm/core/index.js +16 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/index.js +87 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/index.js +11 -0
- package/dist/esm/interfaces/index.js.map +1 -0
- package/dist/esm/layers/index.js +16 -0
- package/dist/esm/layers/index.js.map +1 -0
- package/dist/esm/layers/memory.js +384 -0
- package/dist/esm/layers/memory.js.map +1 -0
- package/dist/esm/layers/postgres.js +485 -0
- package/dist/esm/layers/postgres.js.map +1 -0
- package/dist/esm/layers/redis.js +384 -0
- package/dist/esm/layers/redis.js.map +1 -0
- package/dist/esm/types/index.js +49 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/types/core/client.d.ts +561 -0
- package/dist/types/core/client.d.ts.map +1 -0
- package/dist/types/core/database.d.ts +130 -0
- package/dist/types/core/database.d.ts.map +1 -0
- package/dist/types/core/engine.d.ts +450 -0
- package/dist/types/core/engine.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +13 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +209 -0
- package/dist/types/interfaces/index.d.ts.map +1 -0
- package/dist/types/layers/index.d.ts +16 -0
- package/dist/types/layers/index.d.ts.map +1 -0
- package/dist/types/layers/memory.d.ts +261 -0
- package/dist/types/layers/memory.d.ts.map +1 -0
- package/dist/types/layers/postgres.d.ts +313 -0
- package/dist/types/layers/postgres.d.ts.map +1 -0
- package/dist/types/layers/redis.d.ts +248 -0
- package/dist/types/layers/redis.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +410 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 WG Technology Labs, Waren Gonzaga
|
|
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,427 @@
|
|
|
1
|
+

|
|
2
|
+
<!-- Created with GitHub Repo Banner by Waren Gonzaga: https://ghrb.waren.build -->
|
|
3
|
+
|
|
4
|
+
# Nuvex 🗄️💎 [](https://github.com/wgtechlabs)
|
|
5
|
+
|
|
6
|
+
[](https://github.com/wgtechlabs/nuvex/actions/workflows/package.yml) [](https://codecov.io/gh/wgtechlabs/nuvex) [](https://www.npmjs.com/package/@wgtechlabs/nuvex) [](https://bun.sh) [](https://nodejs.org) [](https://github.com/sponsors/wgtechlabs) [](https://github.com/wgtechlabs/nuvex/releases) [](https://github.com/wgtechlabs/nuvex/stargazers) [](https://github.com/wgtechlabs/nuvex/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**Nuvex** is the ultimate production-ready, TypeScript-first 3-layer storage SDK for Bun and Node.js applications. Combining the speed of memory cache, the reliability of Redis, and the persistence of PostgreSQL — all with one simple API and zero configuration hassle. Born from real-world development challenges and proven in production environments, Nuvex delivers enterprise-grade storage with intelligent caching that actually works.
|
|
9
|
+
|
|
10
|
+
The first storage SDK with built-in automatic data promotion/demotion, comprehensive health monitoring, and backup/restore capabilities. Stop wrestling with complex storage configurations and start building amazing applications with confidence. Whether you're creating high-performance APIs, developing microservices, or deploying production servers, Nuvex provides intelligent multi-layer storage that scales with your application's growth — from your first prototype to handling millions of requests across distributed systems.
|
|
11
|
+
|
|
12
|
+
## ⚡ Why Developers Choose Nuvex
|
|
13
|
+
|
|
14
|
+
**Tired of juggling Redis, PostgreSQL, and in-memory caches?** You're not alone.
|
|
15
|
+
|
|
16
|
+
Every developer has been there: your app is slow because you're hitting the database for every request. You add Redis, now you're managing cache invalidation. You add memory caching, now you're dealing with three different APIs and complex fallback logic. One service goes down, your entire storage layer breaks.
|
|
17
|
+
|
|
18
|
+
**Nuvex solves this once and for all:**
|
|
19
|
+
|
|
20
|
+
- **🎯 One API, Zero Headaches**: Write `storage.set()` and `storage.get()` — Nuvex handles Memory → Redis → PostgreSQL automatically
|
|
21
|
+
- **⚡ Performance That Just Works**: Sub-millisecond access for hot data, with intelligent promotion keeping your most-used data blazing fast
|
|
22
|
+
- **🛡️ Production-Grade Reliability**: Battle-tested with automatic error recovery and graceful fallbacks when services go down
|
|
23
|
+
- **📊 Built-in Observability**: Real-time metrics and health monitoring so you know exactly what's happening
|
|
24
|
+
- **💪 TypeScript-First DX**: Full type safety and excellent IntelliSense that makes coding a joy
|
|
25
|
+
- **🔧 Zero Configuration**: Works perfectly out of the box — no complex setup, no YAML files, no DevOps nightmares
|
|
26
|
+
|
|
27
|
+
**The result?** You focus on building features while Nuvex handles the storage complexity. From prototype to production, from thousands to millions of requests — storage that scales with your ambitions.
|
|
28
|
+
|
|
29
|
+
**Ready to 10x your storage performance?** [Get started now](#-quick-start) ⚡
|
|
30
|
+
|
|
31
|
+
## 🤗 Special Thanks
|
|
32
|
+
|
|
33
|
+
<!-- markdownlint-disable MD033 -->
|
|
34
|
+
| <div align="center">💎 Platinum Sponsor</div> |
|
|
35
|
+
|:-------------------------------------------:|
|
|
36
|
+
| <a href="https://unthread.com"><img src="https://raw.githubusercontent.com/wgtechlabs/unthread-discord-bot/main/.github/assets/sponsors/platinum_unthread.png" width="250" alt="Unthread"></a> |
|
|
37
|
+
| <div align="center"><a href="https://unthread.com" target="_blank"><b>Unthread</b></a><br/>Streamlined support ticketing for modern teams.</div> |
|
|
38
|
+
<!-- markdownlint-enable MD033 -->
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Bun (recommended)
|
|
44
|
+
bun add @wgtechlabs/nuvex pg redis
|
|
45
|
+
|
|
46
|
+
# npm / Node.js
|
|
47
|
+
npm install @wgtechlabs/nuvex pg redis
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { NuvexClient } from '@wgtechlabs/nuvex';
|
|
52
|
+
|
|
53
|
+
// Initialize once, use everywhere
|
|
54
|
+
const storage = await NuvexClient.initialize({
|
|
55
|
+
postgres: {
|
|
56
|
+
host: 'localhost',
|
|
57
|
+
port: 5432,
|
|
58
|
+
database: 'myapp',
|
|
59
|
+
user: 'postgres',
|
|
60
|
+
password: 'password'
|
|
61
|
+
},
|
|
62
|
+
redis: { url: 'redis://localhost:6379' } // Optional but recommended
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Simple, powerful API
|
|
66
|
+
await storage.set('user:123', { name: 'John', email: 'john@example.com' });
|
|
67
|
+
const user = await storage.get('user:123');
|
|
68
|
+
await storage.delete('user:123');
|
|
69
|
+
|
|
70
|
+
// Namespace your data
|
|
71
|
+
await storage.setNamespaced('sessions', 'abc123', { userId: 789, expires: Date.now() + 3600000 });
|
|
72
|
+
const session = await storage.getNamespaced('sessions', 'abc123');
|
|
73
|
+
|
|
74
|
+
// Batch operations for efficiency
|
|
75
|
+
const results = await storage.setBatch([
|
|
76
|
+
{ operation: 'set', key: 'product:1', value: { name: 'iPhone', price: 999 } },
|
|
77
|
+
{ operation: 'set', key: 'product:2', value: { name: 'MacBook', price: 1999 } }
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
// Health monitoring
|
|
81
|
+
const health = await storage.healthCheck();
|
|
82
|
+
console.log('Storage healthy:', health.overall);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 📦 Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Bun (recommended)
|
|
89
|
+
bun add @wgtechlabs/nuvex pg redis
|
|
90
|
+
|
|
91
|
+
# npm / Node.js
|
|
92
|
+
npm install @wgtechlabs/nuvex pg redis
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 🎯 Perfect For Any JavaScript Application
|
|
96
|
+
|
|
97
|
+
- **🌐 Web APIs**: Session management, response caching, rate limiting
|
|
98
|
+
- **🛒 E-commerce**: Product catalogs, shopping carts, user preferences
|
|
99
|
+
- **🎮 Gaming**: Player data, leaderboards, real-time game state
|
|
100
|
+
- **🤖 Bots & Automation**: User state, conversation flow, command history
|
|
101
|
+
- **📱 Mobile Backends**: User profiles, app data, push notifications
|
|
102
|
+
- **🏢 Enterprise**: Configuration management, temporary data, metrics
|
|
103
|
+
- **📊 Analytics**: Event storage, metrics aggregation, reporting data
|
|
104
|
+
|
|
105
|
+
## 📚 Documentation
|
|
106
|
+
|
|
107
|
+
### Configuration
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
const config = {
|
|
111
|
+
postgres: {
|
|
112
|
+
host: 'localhost',
|
|
113
|
+
port: 5432,
|
|
114
|
+
database: 'myapp',
|
|
115
|
+
user: 'postgres',
|
|
116
|
+
password: 'password'
|
|
117
|
+
},
|
|
118
|
+
redis: { url: 'redis://localhost:6379' }, // Optional but recommended
|
|
119
|
+
memory: { ttl: 86400000, maxSize: 10000 }, // Optional
|
|
120
|
+
logging: { enabled: true } // Optional
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### PostgreSQL Schema Configuration
|
|
125
|
+
|
|
126
|
+
Nuvex uses strongly branded table and column names by default (`nuvex_storage`, `nuvex_key`, `nuvex_data`). For backwards compatibility with existing applications, you can customize these names:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
// Default configuration (recommended for new apps)
|
|
130
|
+
const storage = await NuvexClient.initialize({
|
|
131
|
+
postgres: {
|
|
132
|
+
host: 'localhost',
|
|
133
|
+
port: 5432,
|
|
134
|
+
database: 'myapp',
|
|
135
|
+
user: 'postgres',
|
|
136
|
+
password: 'password'
|
|
137
|
+
// Uses: table 'nuvex_storage', columns 'nuvex_key' and 'nuvex_data'
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Custom configuration for Telegram bot compatibility
|
|
142
|
+
const storage = await NuvexClient.initialize({
|
|
143
|
+
postgres: {
|
|
144
|
+
host: 'localhost',
|
|
145
|
+
port: 5432,
|
|
146
|
+
database: 'telegram_bot',
|
|
147
|
+
user: 'postgres',
|
|
148
|
+
password: 'password',
|
|
149
|
+
schema: {
|
|
150
|
+
tableName: 'storage_cache',
|
|
151
|
+
columns: {
|
|
152
|
+
key: 'key',
|
|
153
|
+
value: 'value'
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Custom configuration for Discord bot compatibility
|
|
160
|
+
const storage = await NuvexClient.initialize({
|
|
161
|
+
postgres: {
|
|
162
|
+
host: 'localhost',
|
|
163
|
+
port: 5432,
|
|
164
|
+
database: 'discord_bot',
|
|
165
|
+
user: 'postgres',
|
|
166
|
+
password: 'password',
|
|
167
|
+
schema: {
|
|
168
|
+
tableName: 'storage_cache',
|
|
169
|
+
columns: {
|
|
170
|
+
key: 'cache_key',
|
|
171
|
+
value: 'data'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Schema Configuration Reference:**
|
|
179
|
+
|
|
180
|
+
| App | Table | Key Column | Data Column |
|
|
181
|
+
|---------------|-----------------|---------------|---------------|
|
|
182
|
+
| **Nuvex** (default) | nuvex_storage | nuvex_key | nuvex_data |
|
|
183
|
+
| Telegram Bot | storage_cache | key | value |
|
|
184
|
+
| Discord Bot | storage_cache | cache_key | data |
|
|
185
|
+
|
|
186
|
+
### API Reference
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
// Basic operations
|
|
190
|
+
await storage.set('key', value, { ttl: 3600 });
|
|
191
|
+
const data = await storage.get('key');
|
|
192
|
+
await storage.delete('key');
|
|
193
|
+
await storage.exists('key');
|
|
194
|
+
|
|
195
|
+
// Namespace operations
|
|
196
|
+
await storage.setNamespaced('users', '123', userData);
|
|
197
|
+
const user = await storage.getNamespaced('users', '123');
|
|
198
|
+
|
|
199
|
+
// Batch operations
|
|
200
|
+
const results = await storage.setBatch([
|
|
201
|
+
{ operation: 'set', key: 'key1', value: 'value1' },
|
|
202
|
+
{ operation: 'get', key: 'key2' }
|
|
203
|
+
]);
|
|
204
|
+
|
|
205
|
+
// Atomic operations
|
|
206
|
+
const newValue = await storage.increment('counter', 5);
|
|
207
|
+
await storage.decrement('counter', 2);
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Monitoring & Maintenance
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// Health monitoring
|
|
214
|
+
const health = await storage.healthCheck();
|
|
215
|
+
console.log('All systems:', health.overall ? '✅' : '❌');
|
|
216
|
+
|
|
217
|
+
// Performance metrics
|
|
218
|
+
const metrics = storage.getMetrics();
|
|
219
|
+
console.log(`Cache hit rate: ${(metrics.memoryHits / metrics.totalOperations * 100).toFixed(2)}%`);
|
|
220
|
+
|
|
221
|
+
// Backup & restore
|
|
222
|
+
const backupId = await storage.backup('my-backup', { compression: true });
|
|
223
|
+
await storage.restore('my-backup', { clearExisting: false });
|
|
224
|
+
|
|
225
|
+
// Query operations
|
|
226
|
+
const results = await storage.query({
|
|
227
|
+
pattern: 'user:*',
|
|
228
|
+
limit: 100,
|
|
229
|
+
sortBy: 'createdAt'
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Alternative Loggers
|
|
234
|
+
|
|
235
|
+
Nuvex supports any logger that implements the simple interface:
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
// With Winston
|
|
239
|
+
import winston from 'winston';
|
|
240
|
+
const logger = winston.createLogger({
|
|
241
|
+
level: 'info',
|
|
242
|
+
format: winston.format.json(),
|
|
243
|
+
transports: [new winston.transports.Console()]
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// With Pino
|
|
247
|
+
import pino from 'pino';
|
|
248
|
+
const logger = pino({ level: 'info' });
|
|
249
|
+
|
|
250
|
+
// With Console (development)
|
|
251
|
+
const logger = console;
|
|
252
|
+
|
|
253
|
+
// Use any logger
|
|
254
|
+
const storage = new Nuvex({
|
|
255
|
+
postgres: { /* ... */ },
|
|
256
|
+
logging: { enabled: true, logger }
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Logging
|
|
261
|
+
|
|
262
|
+
Nuvex supports pluggable logging with any logger that implements the simple interface.
|
|
263
|
+
|
|
264
|
+
### 🔥 Recommended: @wgtechlabs/log-engine
|
|
265
|
+
|
|
266
|
+
[`@wgtechlabs/log-engine`](https://github.com/wgtechlabs/log-engine) is specifically designed to work seamlessly with Nuvex:
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { LogEngine } from '@wgtechlabs/log-engine';
|
|
270
|
+
import { Nuvex } from '@wgtechlabs/nuvex';
|
|
271
|
+
|
|
272
|
+
// One-time configuration
|
|
273
|
+
LogEngine.configure({
|
|
274
|
+
level: 'info',
|
|
275
|
+
service: 'my-app',
|
|
276
|
+
structured: true,
|
|
277
|
+
colorize: true
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const storage = new Nuvex({
|
|
281
|
+
postgres: { /* config */ },
|
|
282
|
+
logging: {
|
|
283
|
+
enabled: true,
|
|
284
|
+
logger: LogEngine,
|
|
285
|
+
includeMetrics: true // Cache hit/miss rates
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Benefits of log-engine with Nuvex:**
|
|
291
|
+
|
|
292
|
+
- 🎯 **Structured Logging** - Perfect for monitoring Nuvex metrics
|
|
293
|
+
- ⚡ **High Performance** - Minimal overhead for storage operations
|
|
294
|
+
- 🔧 **Easy Configuration** - Works out of the box
|
|
295
|
+
- 📊 **Rich Context** - Detailed operation metadata
|
|
296
|
+
|
|
297
|
+
### Other Supported Loggers
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
// Winston
|
|
301
|
+
import winston from 'winston';
|
|
302
|
+
const logger = winston.createLogger({ level: 'info' });
|
|
303
|
+
|
|
304
|
+
// Pino
|
|
305
|
+
import pino from 'pino';
|
|
306
|
+
const logger = pino();
|
|
307
|
+
|
|
308
|
+
// Console (development)
|
|
309
|
+
const logger = console;
|
|
310
|
+
|
|
311
|
+
// Custom logger (just implement the interface)
|
|
312
|
+
const logger = {
|
|
313
|
+
debug: (msg, meta) => { /* your implementation */ },
|
|
314
|
+
info: (msg, meta) => { /* your implementation */ },
|
|
315
|
+
warn: (msg, meta) => { /* your implementation */ },
|
|
316
|
+
error: (msg, meta) => { /* your implementation */ }
|
|
317
|
+
};
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### API Reference
|
|
321
|
+
|
|
322
|
+
#### Core Operations
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
// Basic CRUD operations
|
|
326
|
+
await storage.set(key, value, options?);
|
|
327
|
+
await storage.get(key, options?);
|
|
328
|
+
await storage.delete(key);
|
|
329
|
+
await storage.exists(key);
|
|
330
|
+
|
|
331
|
+
// Batch operations
|
|
332
|
+
await storage.setBatch([
|
|
333
|
+
{ operation: 'set', key: 'key1', value: 'value1' },
|
|
334
|
+
{ operation: 'set', key: 'key2', value: 'value2' }
|
|
335
|
+
]);
|
|
336
|
+
|
|
337
|
+
// Query operations
|
|
338
|
+
const results = await storage.query({
|
|
339
|
+
pattern: 'user:*',
|
|
340
|
+
limit: 10,
|
|
341
|
+
sortBy: 'createdAt'
|
|
342
|
+
});
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### Advanced Features
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
// Force specific storage layer
|
|
349
|
+
await storage.set('key', value, { layer: StorageLayer.POSTGRES });
|
|
350
|
+
|
|
351
|
+
// Skip cache layers
|
|
352
|
+
await storage.get('key', { skipCache: true });
|
|
353
|
+
|
|
354
|
+
// Layer management
|
|
355
|
+
await storage.promote('key', StorageLayer.MEMORY);
|
|
356
|
+
await storage.demote('key', StorageLayer.POSTGRES);
|
|
357
|
+
|
|
358
|
+
// Metrics and monitoring
|
|
359
|
+
const metrics = storage.getMetrics();
|
|
360
|
+
const health = await storage.healthCheck();
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## 🏗️ How It Works
|
|
364
|
+
|
|
365
|
+
**3-Layer Architecture** → **Automatic Optimization** → **Lightning Fast**
|
|
366
|
+
|
|
367
|
+
1. **Memory** (< 1ms) → **Redis** (1-5ms) → **PostgreSQL** (5-50ms)
|
|
368
|
+
2. **Smart promotion**: Hot data moves to faster layers automatically
|
|
369
|
+
3. **Graceful fallback**: If Redis is down, PostgreSQL takes over seamlessly
|
|
370
|
+
4. **Zero config**: Works perfectly out of the box with sensible defaults
|
|
371
|
+
|
|
372
|
+
## 🤝 Community & Support
|
|
373
|
+
|
|
374
|
+
- 💬 **[GitHub Discussions](https://github.com/wgtechlabs/nuvex/discussions)** - Ask questions, share ideas
|
|
375
|
+
- 🐛 **[Issues](https://github.com/wgtechlabs/nuvex/issues)** - Report bugs, request features
|
|
376
|
+
- 📖 **[Documentation](https://github.com/wgtechlabs/nuvex#readme)** - Complete API reference
|
|
377
|
+
- ⭐ **[Star this repo](https://github.com/wgtechlabs/nuvex)** - Show your support!
|
|
378
|
+
|
|
379
|
+
## 🎯 Contributing
|
|
380
|
+
|
|
381
|
+
We ❤️ contributions! Here's how you can help:
|
|
382
|
+
|
|
383
|
+
- **🐛 Report bugs** - Found an issue? [Open an issue](https://github.com/wgtechlabs/nuvex/issues/new)
|
|
384
|
+
- **💡 Suggest features** - Have ideas? [Start a discussion](https://github.com/wgtechlabs/nuvex/discussions)
|
|
385
|
+
- **📝 Improve docs** - Help make our documentation better
|
|
386
|
+
- **🔧 Submit PRs** - Check out our [contributing guide](./CONTRIBUTING.md) to get started
|
|
387
|
+
|
|
388
|
+
## 🛟 Help & Support
|
|
389
|
+
|
|
390
|
+
Need assistance? Here's how to get support:
|
|
391
|
+
|
|
392
|
+
- **Community Support**: Check the [Help & Support](https://github.com/wgtechlabs/nuvex/discussions/categories/help-support) discussions
|
|
393
|
+
- **Ask Questions**: Create a [new discussion](https://github.com/wgtechlabs/nuvex/discussions/new?category=help-support)
|
|
394
|
+
- **Security Issues**: Follow our [security policy](./security.md) for responsible disclosure
|
|
395
|
+
|
|
396
|
+
## 🙏 Sponsor
|
|
397
|
+
|
|
398
|
+
Like this project? **Leave a star**! ⭐⭐⭐⭐⭐
|
|
399
|
+
|
|
400
|
+
There are several ways you can support this project:
|
|
401
|
+
|
|
402
|
+
- [Become a sponsor](https://github.com/sponsors/wgtechlabs) and get some perks! 💖
|
|
403
|
+
- [Buy me a coffee](https://buymeacoffee.com/wgtechlabs) if you just love what I do! ☕
|
|
404
|
+
|
|
405
|
+
## ⭐ GitHub Star Nomination
|
|
406
|
+
|
|
407
|
+
Found this project helpful? Consider nominating me **(@warengonzaga)** for the [GitHub Star program](https://stars.github.com/nominate/)! This recognition supports ongoing development of this project and [my other open-source projects](https://github.com/warengonzaga?tab=repositories). GitHub Stars are recognized for their significant contributions to the developer community - your nomination makes a difference and encourages continued innovation!
|
|
408
|
+
|
|
409
|
+
## 📋 Code of Conduct
|
|
410
|
+
|
|
411
|
+
I'm committed to providing a welcoming and inclusive environment for all contributors and users. Please review the project's [Code of Conduct](./code_of_conduct.md) to understand the community standards and expectations for participation.
|
|
412
|
+
|
|
413
|
+
## 📄 License
|
|
414
|
+
|
|
415
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
416
|
+
|
|
417
|
+
## 📝 Author
|
|
418
|
+
|
|
419
|
+
This project is created by **[Waren Gonzaga](https://github.com/warengonzaga)** at [WG Technology Labs](https://github.com/wgtechlabs), with the help of awesome *[contributors](https://github.com/wgtechlabs/nuvex/graphs/contributors)*.
|
|
420
|
+
|
|
421
|
+
[](https://github.com/wgtechlabs/nuvex/graphs/contributors)
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
💻 with ❤️ by [Waren Gonzaga](https://warengonzaga.com) at [WG Technology Labs](https://wgtechlabs.com), and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) 🙏
|
|
426
|
+
|
|
427
|
+
<!-- GitAds-Verify: [TO_BE_CONFIGURED] -->
|