@rabstack/rab-api 1.10.1 → 1.11.0
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/index.cjs.js +6 -2
- package/index.esm.js +6 -2
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -530,9 +530,9 @@ const DEFAULT_STRATEGY = 'url-query';
|
|
|
530
530
|
strategy: DEFAULT_STRATEGY
|
|
531
531
|
};
|
|
532
532
|
}
|
|
533
|
-
var
|
|
533
|
+
var _cache_strategy;
|
|
534
534
|
return {
|
|
535
|
-
ttl:
|
|
535
|
+
ttl: cache.ttl,
|
|
536
536
|
strategy: (_cache_strategy = cache.strategy) != null ? _cache_strategy : DEFAULT_STRATEGY,
|
|
537
537
|
purge: cache.purge
|
|
538
538
|
};
|
|
@@ -620,8 +620,10 @@ const controllerHandler = (controller, config)=>{
|
|
|
620
620
|
const cacheKey = buildCacheKey(req, cacheConfig.strategy);
|
|
621
621
|
const cached = await cacheAdapter.get(cacheKey);
|
|
622
622
|
if (cached) {
|
|
623
|
+
console.log(`[rab-api] Cache hit - serving cached response for: ${cacheKey}`);
|
|
623
624
|
return res.status(200).json(cached);
|
|
624
625
|
}
|
|
626
|
+
console.log(`[rab-api] Cache miss - fetching fresh data for: ${cacheKey}`);
|
|
625
627
|
}
|
|
626
628
|
const response = await controller.handler(_extends({}, req, {
|
|
627
629
|
query,
|
|
@@ -639,6 +641,7 @@ const controllerHandler = (controller, config)=>{
|
|
|
639
641
|
// Cache the response after successful execution (GET only)
|
|
640
642
|
if (isCacheEnabled && isGetRequest) {
|
|
641
643
|
const cacheKey = buildCacheKey(req, cacheConfig.strategy);
|
|
644
|
+
console.log(`[rab-api] Caching response for ${cacheConfig.ttl}s: ${cacheKey}`);
|
|
642
645
|
// Don't await - cache in background
|
|
643
646
|
cacheAdapter.set(cacheKey, jsonResponse, cacheConfig.ttl).catch(()=>{
|
|
644
647
|
// Silently ignore cache errors
|
|
@@ -647,6 +650,7 @@ const controllerHandler = (controller, config)=>{
|
|
|
647
650
|
// Handle purge after successful mutation
|
|
648
651
|
if (hasPurge && cacheAdapter) {
|
|
649
652
|
const keys = resolvePurgeKeys(cacheConfig.purge, req);
|
|
653
|
+
console.log(`[rab-api] Purging cache keys: ${keys.join(', ')}`);
|
|
650
654
|
// Purge in background no await for promises you could use setImmediate if needed
|
|
651
655
|
Promise.all(keys.map((key)=>cacheAdapter.del(key))).catch(()=>{
|
|
652
656
|
// Silently ignore purge errors
|
package/index.esm.js
CHANGED
|
@@ -528,9 +528,9 @@ const DEFAULT_STRATEGY = 'url-query';
|
|
|
528
528
|
strategy: DEFAULT_STRATEGY
|
|
529
529
|
};
|
|
530
530
|
}
|
|
531
|
-
var
|
|
531
|
+
var _cache_strategy;
|
|
532
532
|
return {
|
|
533
|
-
ttl:
|
|
533
|
+
ttl: cache.ttl,
|
|
534
534
|
strategy: (_cache_strategy = cache.strategy) != null ? _cache_strategy : DEFAULT_STRATEGY,
|
|
535
535
|
purge: cache.purge
|
|
536
536
|
};
|
|
@@ -618,8 +618,10 @@ const controllerHandler = (controller, config)=>{
|
|
|
618
618
|
const cacheKey = buildCacheKey(req, cacheConfig.strategy);
|
|
619
619
|
const cached = await cacheAdapter.get(cacheKey);
|
|
620
620
|
if (cached) {
|
|
621
|
+
console.log(`[rab-api] Cache hit - serving cached response for: ${cacheKey}`);
|
|
621
622
|
return res.status(200).json(cached);
|
|
622
623
|
}
|
|
624
|
+
console.log(`[rab-api] Cache miss - fetching fresh data for: ${cacheKey}`);
|
|
623
625
|
}
|
|
624
626
|
const response = await controller.handler(_extends({}, req, {
|
|
625
627
|
query,
|
|
@@ -637,6 +639,7 @@ const controllerHandler = (controller, config)=>{
|
|
|
637
639
|
// Cache the response after successful execution (GET only)
|
|
638
640
|
if (isCacheEnabled && isGetRequest) {
|
|
639
641
|
const cacheKey = buildCacheKey(req, cacheConfig.strategy);
|
|
642
|
+
console.log(`[rab-api] Caching response for ${cacheConfig.ttl}s: ${cacheKey}`);
|
|
640
643
|
// Don't await - cache in background
|
|
641
644
|
cacheAdapter.set(cacheKey, jsonResponse, cacheConfig.ttl).catch(()=>{
|
|
642
645
|
// Silently ignore cache errors
|
|
@@ -645,6 +648,7 @@ const controllerHandler = (controller, config)=>{
|
|
|
645
648
|
// Handle purge after successful mutation
|
|
646
649
|
if (hasPurge && cacheAdapter) {
|
|
647
650
|
const keys = resolvePurgeKeys(cacheConfig.purge, req);
|
|
651
|
+
console.log(`[rab-api] Purging cache keys: ${keys.join(', ')}`);
|
|
648
652
|
// Purge in background no await for promises you could use setImmediate if needed
|
|
649
653
|
Promise.all(keys.map((key)=>cacheAdapter.del(key))).catch(()=>{
|
|
650
654
|
// Silently ignore purge errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabstack/rab-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "A TypeScript REST API framework built on Express.js with decorator-based routing, dependency injection, and built-in validation",
|
|
5
5
|
"author": "Softin",
|
|
6
6
|
"license": "MIT",
|