@rabstack/rab-api 1.10.2 → 1.11.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/index.cjs.js +7 -3
- package/index.esm.js +7 -3
- package/package.json +2 -2
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
|
};
|
|
@@ -552,7 +552,7 @@ const DEFAULT_STRATEGY = 'url-query';
|
|
|
552
552
|
// url-query: path + sorted query string
|
|
553
553
|
const query = req.query;
|
|
554
554
|
if (query && Object.keys(query).length > 0) {
|
|
555
|
-
const sortedQuery = Object.keys(query).sort().map((key)=>`${key}=${query[key]}`).join('&');
|
|
555
|
+
const sortedQuery = Object.keys(query).sort().map((key)=>`${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`).join('&');
|
|
556
556
|
return `${path}?${sortedQuery}`;
|
|
557
557
|
}
|
|
558
558
|
return path;
|
|
@@ -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
|
};
|
|
@@ -550,7 +550,7 @@ const DEFAULT_STRATEGY = 'url-query';
|
|
|
550
550
|
// url-query: path + sorted query string
|
|
551
551
|
const query = req.query;
|
|
552
552
|
if (query && Object.keys(query).length > 0) {
|
|
553
|
-
const sortedQuery = Object.keys(query).sort().map((key)=>`${key}=${query[key]}`).join('&');
|
|
553
|
+
const sortedQuery = Object.keys(query).sort().map((key)=>`${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`).join('&');
|
|
554
554
|
return `${path}?${sortedQuery}`;
|
|
555
555
|
}
|
|
556
556
|
return path;
|
|
@@ -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.1",
|
|
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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"express": "^5.1.0",
|
|
22
|
-
"typedi": "
|
|
22
|
+
"typedi": "0.10.0",
|
|
23
23
|
"jsonwebtoken": "^9.0.0",
|
|
24
24
|
"compose-middleware": "^5.0.0",
|
|
25
25
|
"reflect-metadata": "^0.2.2"
|