@thisisagile/easy 12.1.10 → 12.2.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.
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
export declare class CacheControl {
|
|
2
|
-
private age;
|
|
3
|
-
private stale?;
|
|
4
2
|
readonly enabled: boolean;
|
|
5
|
-
|
|
3
|
+
protected constructor(enabled?: boolean);
|
|
4
|
+
protected _maxAge?: number;
|
|
5
|
+
protected _sharedMaxAge?: number;
|
|
6
|
+
protected _noCache?: boolean;
|
|
7
|
+
protected _mustRevalidate?: boolean;
|
|
8
|
+
protected _private?: boolean;
|
|
9
|
+
protected _public?: boolean;
|
|
10
|
+
protected _immutable?: boolean;
|
|
11
|
+
protected _staleWhileRevalidate?: number;
|
|
6
12
|
static disabled: () => CacheControl;
|
|
7
13
|
static OneSecond: () => CacheControl;
|
|
8
14
|
static fiveSeconds: () => CacheControl;
|
|
9
15
|
static tenSeconds: () => CacheControl;
|
|
10
16
|
static thirtySeconds: () => CacheControl;
|
|
11
17
|
static sixtySeconds: () => CacheControl;
|
|
12
|
-
static custom: (maxAge
|
|
13
|
-
maxAge: (a
|
|
14
|
-
|
|
18
|
+
static custom: (maxAge?: number, staleWhileRevalidate?: number) => CacheControl;
|
|
19
|
+
readonly maxAge: (a?: number) => this;
|
|
20
|
+
readonly sharedMaxAge: (a?: number) => this;
|
|
21
|
+
readonly noCache: (a?: boolean) => this;
|
|
22
|
+
readonly mustRevalidate: (a?: boolean) => this;
|
|
23
|
+
readonly private: (a?: boolean) => this;
|
|
24
|
+
readonly public: (a?: boolean) => this;
|
|
25
|
+
readonly immutable: (a?: boolean) => this;
|
|
26
|
+
readonly staleWhileRevalidate: (a?: number) => this;
|
|
15
27
|
value: () => string;
|
|
16
28
|
name: string;
|
|
17
29
|
}
|
|
@@ -3,27 +3,57 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CacheControl = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
class CacheControl {
|
|
6
|
-
constructor(
|
|
7
|
-
this.age = age;
|
|
8
|
-
this.stale = stale;
|
|
6
|
+
constructor(enabled = true) {
|
|
9
7
|
this.enabled = enabled;
|
|
10
8
|
this.maxAge = (a) => {
|
|
11
|
-
this.
|
|
9
|
+
this._maxAge = a;
|
|
12
10
|
return this;
|
|
13
11
|
};
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
12
|
+
this.sharedMaxAge = (a) => {
|
|
13
|
+
this._sharedMaxAge = a;
|
|
14
|
+
return this;
|
|
15
|
+
};
|
|
16
|
+
this.noCache = (a) => {
|
|
17
|
+
this._noCache = a;
|
|
18
|
+
return this;
|
|
19
|
+
};
|
|
20
|
+
this.mustRevalidate = (a) => {
|
|
21
|
+
this._mustRevalidate = a;
|
|
22
|
+
return this;
|
|
23
|
+
};
|
|
24
|
+
this.private = (a) => {
|
|
25
|
+
this._private = a;
|
|
26
|
+
return this;
|
|
27
|
+
};
|
|
28
|
+
this.public = (a) => {
|
|
29
|
+
this._public = a;
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
this.immutable = (a) => {
|
|
33
|
+
this._immutable = a;
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
this.staleWhileRevalidate = (a) => {
|
|
37
|
+
this._staleWhileRevalidate = a;
|
|
16
38
|
return this;
|
|
17
39
|
};
|
|
18
40
|
this.value = () => {
|
|
19
|
-
const
|
|
20
|
-
|
|
41
|
+
const directives = [];
|
|
42
|
+
(0, types_1.isDefined)(this._maxAge) && directives.push(`max-age=${this._maxAge}`);
|
|
43
|
+
(0, types_1.isDefined)(this._sharedMaxAge) && directives.push(`s-maxage=${this._sharedMaxAge}`);
|
|
44
|
+
this._noCache === true && directives.push(`no-cache`);
|
|
45
|
+
this._mustRevalidate === true && directives.push(`must-revalidate`);
|
|
46
|
+
this._private === true && directives.push(`private`);
|
|
47
|
+
this._public === true && directives.push(`public`);
|
|
48
|
+
this._immutable === true && directives.push(`immutable`);
|
|
49
|
+
(0, types_1.isDefined)(this._staleWhileRevalidate) && directives.push(`stale-while-revalidate=${this._staleWhileRevalidate}`);
|
|
50
|
+
return directives.join(',');
|
|
21
51
|
};
|
|
22
52
|
this.name = 'Cache-Control';
|
|
23
53
|
}
|
|
24
54
|
}
|
|
25
55
|
exports.CacheControl = CacheControl;
|
|
26
|
-
CacheControl.disabled = () => new CacheControl(
|
|
56
|
+
CacheControl.disabled = () => new CacheControl(false);
|
|
27
57
|
CacheControl.OneSecond = () => new CacheControl().maxAge(1).staleWhileRevalidate(1);
|
|
28
58
|
CacheControl.fiveSeconds = () => new CacheControl().maxAge(5).staleWhileRevalidate(5);
|
|
29
59
|
CacheControl.tenSeconds = () => new CacheControl().maxAge(10).staleWhileRevalidate(10);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheControl.js","sourceRoot":"","sources":["../../src/http/CacheControl.ts"],"names":[],"mappings":";;;AAAA,oCAAqC;AAErC,MAAa,YAAY;IACvB,
|
|
1
|
+
{"version":3,"file":"CacheControl.js","sourceRoot":"","sources":["../../src/http/CacheControl.ts"],"names":[],"mappings":";;;AAAA,oCAAqC;AAErC,MAAa,YAAY;IACvB,YAA+B,UAAU,IAAI;QAAd,YAAO,GAAP,OAAO,CAAO;QAmBpC,WAAM,GAAG,CAAC,CAAU,EAAQ,EAAE;YACrC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEO,iBAAY,GAAG,CAAC,CAAU,EAAQ,EAAE;YAC3C,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEO,YAAO,GAAG,CAAC,CAAW,EAAQ,EAAE;YACvC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEO,mBAAc,GAAG,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AC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "12.1
|
|
3
|
+
"version": "12.2.1",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "12.1
|
|
34
|
+
"@thisisagile/easy-test": "12.2.1",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.9",
|
|
37
37
|
"@types/luxon": "3.0.0",
|
package/src/http/CacheControl.ts
CHANGED
|
@@ -1,29 +1,76 @@
|
|
|
1
1
|
import { isDefined } from '../types';
|
|
2
2
|
|
|
3
3
|
export class CacheControl {
|
|
4
|
-
|
|
4
|
+
protected constructor(readonly enabled = true) {}
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
protected _maxAge?: number;
|
|
7
|
+
protected _sharedMaxAge?: number;
|
|
8
|
+
protected _noCache?: boolean;
|
|
9
|
+
protected _mustRevalidate?: boolean;
|
|
10
|
+
protected _private?: boolean;
|
|
11
|
+
protected _public?: boolean;
|
|
12
|
+
protected _immutable?: boolean;
|
|
13
|
+
protected _staleWhileRevalidate?: number;
|
|
14
|
+
|
|
15
|
+
static disabled = () => new CacheControl(false);
|
|
7
16
|
static OneSecond = () => new CacheControl().maxAge(1).staleWhileRevalidate(1);
|
|
8
17
|
static fiveSeconds = () => new CacheControl().maxAge(5).staleWhileRevalidate(5);
|
|
9
18
|
static tenSeconds = () => new CacheControl().maxAge(10).staleWhileRevalidate(10);
|
|
10
19
|
static thirtySeconds = () => new CacheControl().maxAge(30).staleWhileRevalidate(30);
|
|
11
20
|
static sixtySeconds = () => new CacheControl().maxAge(60).staleWhileRevalidate(60);
|
|
12
|
-
static custom = (maxAge
|
|
21
|
+
static custom = (maxAge?: number, staleWhileRevalidate?: number) => new CacheControl().maxAge(maxAge).staleWhileRevalidate(staleWhileRevalidate);
|
|
22
|
+
|
|
23
|
+
readonly maxAge = (a?: number): this => {
|
|
24
|
+
this._maxAge = a;
|
|
25
|
+
return this;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
readonly sharedMaxAge = (a?: number): this => {
|
|
29
|
+
this._sharedMaxAge = a;
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
readonly noCache = (a?: boolean): this => {
|
|
34
|
+
this._noCache = a;
|
|
35
|
+
return this;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
readonly mustRevalidate = (a?: boolean): this => {
|
|
39
|
+
this._mustRevalidate = a;
|
|
40
|
+
return this;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
readonly private = (a?: boolean): this => {
|
|
44
|
+
this._private = a;
|
|
45
|
+
return this;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
readonly public = (a?: boolean): this => {
|
|
49
|
+
this._public = a;
|
|
50
|
+
return this;
|
|
51
|
+
};
|
|
13
52
|
|
|
14
|
-
|
|
15
|
-
this.
|
|
53
|
+
readonly immutable = (a?: boolean): this => {
|
|
54
|
+
this._immutable = a;
|
|
16
55
|
return this;
|
|
17
56
|
};
|
|
18
57
|
|
|
19
|
-
staleWhileRevalidate = (
|
|
20
|
-
this.
|
|
58
|
+
readonly staleWhileRevalidate = (a?: number): this => {
|
|
59
|
+
this._staleWhileRevalidate = a;
|
|
21
60
|
return this;
|
|
22
61
|
};
|
|
23
62
|
|
|
24
63
|
value = (): string => {
|
|
25
|
-
const
|
|
26
|
-
|
|
64
|
+
const directives: string[] = [];
|
|
65
|
+
isDefined(this._maxAge) && directives.push(`max-age=${this._maxAge}`);
|
|
66
|
+
isDefined(this._sharedMaxAge) && directives.push(`s-maxage=${this._sharedMaxAge}`);
|
|
67
|
+
this._noCache === true && directives.push(`no-cache`);
|
|
68
|
+
this._mustRevalidate === true && directives.push(`must-revalidate`);
|
|
69
|
+
this._private === true && directives.push(`private`);
|
|
70
|
+
this._public === true && directives.push(`public`);
|
|
71
|
+
this._immutable === true && directives.push(`immutable`);
|
|
72
|
+
isDefined(this._staleWhileRevalidate) && directives.push(`stale-while-revalidate=${this._staleWhileRevalidate}`);
|
|
73
|
+
return directives.join(',');
|
|
27
74
|
};
|
|
28
75
|
|
|
29
76
|
name = 'Cache-Control';
|