@maioradv/nestjs-core 1.2.0 → 1.2.2
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/dist/decorators/boolean.transform.d.ts +1 -0
- package/dist/decorators/boolean.transform.js +15 -0
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +1 -0
- package/dist/interceptors/http-cache.interceptor.d.ts +4 -1
- package/dist/interceptors/http-cache.interceptor.js +7 -3
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BooleanTransform: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanTransform = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const class_transformer_1 = require("class-transformer");
|
|
6
|
+
const BooleanTransform = () => {
|
|
7
|
+
return (0, common_1.applyDecorators)((0, class_transformer_1.Transform)(({ value }) => {
|
|
8
|
+
return value === 'true' ? true :
|
|
9
|
+
value === 'false' ? false :
|
|
10
|
+
value === '1' ? true :
|
|
11
|
+
value === '0' ? false :
|
|
12
|
+
value ? true : false;
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
exports.BooleanTransform = BooleanTransform;
|
package/dist/decorators/index.js
CHANGED
|
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api-response-with-rels.decorator"), exports);
|
|
18
|
+
__exportStar(require("./boolean.transform"), exports);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { CacheInterceptor } from "@nestjs/cache-manager";
|
|
2
2
|
import { ExecutionContext } from "@nestjs/common";
|
|
3
|
-
export declare const API_CACHE_CONTROL_HEADER = "
|
|
3
|
+
export declare const API_CACHE_CONTROL_HEADER = "x-api-cache-control";
|
|
4
|
+
export declare enum ApiCacheControl {
|
|
5
|
+
noCache = "no-cache"
|
|
6
|
+
}
|
|
4
7
|
export declare class HttpCacheInterceptor extends CacheInterceptor {
|
|
5
8
|
protected isRequestCacheable(context: ExecutionContext): boolean;
|
|
6
9
|
}
|
|
@@ -6,16 +6,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.HttpCacheInterceptor = exports.API_CACHE_CONTROL_HEADER = void 0;
|
|
9
|
+
exports.HttpCacheInterceptor = exports.ApiCacheControl = exports.API_CACHE_CONTROL_HEADER = void 0;
|
|
10
10
|
const cache_manager_1 = require("@nestjs/cache-manager");
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
|
-
exports.API_CACHE_CONTROL_HEADER = '
|
|
12
|
+
exports.API_CACHE_CONTROL_HEADER = 'x-api-cache-control';
|
|
13
|
+
var ApiCacheControl;
|
|
14
|
+
(function (ApiCacheControl) {
|
|
15
|
+
ApiCacheControl["noCache"] = "no-cache";
|
|
16
|
+
})(ApiCacheControl || (exports.ApiCacheControl = ApiCacheControl = {}));
|
|
13
17
|
let HttpCacheInterceptor = class HttpCacheInterceptor extends cache_manager_1.CacheInterceptor {
|
|
14
18
|
isRequestCacheable(context) {
|
|
15
19
|
if (context.getType() === 'graphql')
|
|
16
20
|
return false;
|
|
17
21
|
const req = context.switchToHttp().getRequest();
|
|
18
|
-
return req.headers[exports.API_CACHE_CONTROL_HEADER] ===
|
|
22
|
+
return req.headers[exports.API_CACHE_CONTROL_HEADER] === ApiCacheControl.noCache ? false : true;
|
|
19
23
|
}
|
|
20
24
|
};
|
|
21
25
|
exports.HttpCacheInterceptor = HttpCacheInterceptor;
|