identity-admin 1.26.2 → 1.26.3

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.
@@ -1,2 +1,3 @@
1
+ import { Request } from 'express';
1
2
  import 'reflect-metadata';
2
- export declare function cached(duration?: number, cachedResponseModifier?: (cachedData: any) => any): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
3
+ export declare function cached(duration?: number, cachedResponseModifier?: (cachedData: any, req: Request) => Promise<any>): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -16,7 +16,11 @@ function cached(
16
16
  /*
17
17
  Duration in ms
18
18
  */
19
- duration, cachedResponseModifier) {
19
+ duration,
20
+ /*
21
+ A handler in case you would like to change any information in the cached data
22
+ */
23
+ cachedResponseModifier) {
20
24
  return function (target, propertyKey, descriptor) {
21
25
  const originalMethod = descriptor.value;
22
26
  descriptor.value = function (req, res, ...args) {
@@ -31,7 +35,7 @@ duration, cachedResponseModifier) {
31
35
  const cachedData = cache.get(cacheKey);
32
36
  if (cachedData) {
33
37
  const parsedData = JSON.parse(cachedData);
34
- return res.send(cachedResponseModifier ? cachedResponseModifier(parsedData) : parsedData);
38
+ return res.send(cachedResponseModifier ? yield cachedResponseModifier(parsedData, req) : parsedData);
35
39
  }
36
40
  const originalSend = res.send;
37
41
  res.send = function (body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identity-admin",
3
- "version": "1.26.2",
3
+ "version": "1.26.3",
4
4
  "description": "",
5
5
  "main": "lib/Dashboard.js",
6
6
  "types": "lib/Dashbord.d.ts",