express-cache-ctrl 1.0.4 → 1.1.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/.github/workflows/node.js.yml +1 -1
- package/package.json +8 -8
- package/test/cache.js +19 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-cache-ctrl",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Express middleware to handle content expiration using Cache-Control header.",
|
|
5
5
|
"main": "src/cache.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"http"
|
|
18
18
|
],
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">= 12.0"
|
|
21
21
|
},
|
|
22
22
|
"author": "Carlos Luis Castro Márquez <carlosluiscastro@gmail.com>",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"express": "^4.
|
|
26
|
-
"ms": "^
|
|
25
|
+
"express": "^4.18.2",
|
|
26
|
+
"ms": "^2.1.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"chai": "^
|
|
30
|
-
"mocha": "^
|
|
31
|
-
"mock-res": "^0.
|
|
32
|
-
"morgan": "^1.
|
|
29
|
+
"chai": "^4.3.7",
|
|
30
|
+
"mocha": "^10.2.0",
|
|
31
|
+
"mock-res": "^0.6.0",
|
|
32
|
+
"morgan": "^1.10.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/test/cache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const expect = require("chai")
|
|
1
|
+
const { expect } = require("chai");
|
|
2
2
|
const ms = require("ms");
|
|
3
3
|
const cache = require("../src/cache");
|
|
4
4
|
const Response = require("./mocks/response");
|
|
@@ -8,11 +8,11 @@ describe("Cache Middleware", function () {
|
|
|
8
8
|
|
|
9
9
|
it("cache disabled", function (done) {
|
|
10
10
|
const middleware = cache.disable();
|
|
11
|
-
expect(middleware).to.not.null
|
|
11
|
+
expect(middleware).to.not.be.null;
|
|
12
12
|
expect(middleware).to.be.a("function");
|
|
13
13
|
runMiddleware(middleware, function (res) {
|
|
14
14
|
const cacheControl = res.get("Cache-Control");
|
|
15
|
-
expect(cacheControl).to.not.null
|
|
15
|
+
expect(cacheControl).to.not.be.null;
|
|
16
16
|
const controls = parseCacheControl(cacheControl);
|
|
17
17
|
expect(controls).to.property("no-store");
|
|
18
18
|
expect(controls).to.property("no-cache");
|
|
@@ -20,7 +20,7 @@ describe("Cache Middleware", function () {
|
|
|
20
20
|
expect(controls).to.property("proxy-revalidate");
|
|
21
21
|
|
|
22
22
|
const pragma = res.get("Pragma");
|
|
23
|
-
expect(pragma).to.not.null
|
|
23
|
+
expect(pragma).to.not.be.null;
|
|
24
24
|
expect(pragma).to.equal("no-cache");
|
|
25
25
|
done();
|
|
26
26
|
});
|
|
@@ -28,11 +28,11 @@ describe("Cache Middleware", function () {
|
|
|
28
28
|
|
|
29
29
|
it("cache secure", function (done) {
|
|
30
30
|
const middleware = cache.secure();
|
|
31
|
-
expect(middleware).to.not.null
|
|
31
|
+
expect(middleware).to.not.be.null;
|
|
32
32
|
expect(middleware).to.be.a("function");
|
|
33
33
|
runMiddleware(middleware, function (res) {
|
|
34
34
|
const cacheControl = res.get("Cache-Control");
|
|
35
|
-
expect(cacheControl).to.not.null
|
|
35
|
+
expect(cacheControl).to.not.be.null;
|
|
36
36
|
expect(cacheControl.indexOf("private")).to.equal(0);
|
|
37
37
|
|
|
38
38
|
const controls = parseCacheControl(cacheControl);
|
|
@@ -42,7 +42,7 @@ describe("Cache Middleware", function () {
|
|
|
42
42
|
expect(controls).to.property("no-transform");
|
|
43
43
|
|
|
44
44
|
const pragma = res.get("Pragma");
|
|
45
|
-
expect(pragma).to.not.null
|
|
45
|
+
expect(pragma).to.not.be.null;
|
|
46
46
|
expect(pragma).to.equal("no-cache");
|
|
47
47
|
done();
|
|
48
48
|
});
|
|
@@ -50,11 +50,11 @@ describe("Cache Middleware", function () {
|
|
|
50
50
|
|
|
51
51
|
it("cache with no TTL", function (done) {
|
|
52
52
|
const middleware = cache.private();
|
|
53
|
-
expect(middleware).to.not.null
|
|
53
|
+
expect(middleware).to.not.be.null;
|
|
54
54
|
expect(middleware).to.be.a("function");
|
|
55
55
|
runMiddleware(middleware, function (res) {
|
|
56
56
|
const cacheControl = res.get("Cache-Control");
|
|
57
|
-
expect(cacheControl).to.not.null
|
|
57
|
+
expect(cacheControl).to.not.be.null;
|
|
58
58
|
|
|
59
59
|
const controls = parseCacheControl(cacheControl);
|
|
60
60
|
expect(controls)
|
|
@@ -66,11 +66,11 @@ describe("Cache Middleware", function () {
|
|
|
66
66
|
|
|
67
67
|
it("cache private", function (done) {
|
|
68
68
|
const middleware = cache.private(ttl);
|
|
69
|
-
expect(middleware).to.not.null
|
|
69
|
+
expect(middleware).to.not.be.null;
|
|
70
70
|
expect(middleware).to.be.a("function");
|
|
71
71
|
runMiddleware(middleware, function (res) {
|
|
72
72
|
const cacheControl = res.get("Cache-Control");
|
|
73
|
-
expect(cacheControl).to.not.null
|
|
73
|
+
expect(cacheControl).to.not.be.null;
|
|
74
74
|
expect(cacheControl.indexOf("private")).to.equal(0);
|
|
75
75
|
|
|
76
76
|
const controls = parseCacheControl(cacheControl);
|
|
@@ -81,11 +81,11 @@ describe("Cache Middleware", function () {
|
|
|
81
81
|
|
|
82
82
|
it("cache private, with custom options", function (done) {
|
|
83
83
|
const middleware = cache.private(ttl, { mustRevalidate: true });
|
|
84
|
-
expect(middleware).to.not.null
|
|
84
|
+
expect(middleware).to.not.be.null;
|
|
85
85
|
expect(middleware).to.be.a("function");
|
|
86
86
|
runMiddleware(middleware, function (res) {
|
|
87
87
|
const cacheControl = res.get("Cache-Control");
|
|
88
|
-
expect(cacheControl).to.not.null
|
|
88
|
+
expect(cacheControl).to.not.be.null;
|
|
89
89
|
expect(cacheControl.indexOf("private")).to.equal(0);
|
|
90
90
|
|
|
91
91
|
const controls = parseCacheControl(cacheControl);
|
|
@@ -97,11 +97,11 @@ describe("Cache Middleware", function () {
|
|
|
97
97
|
|
|
98
98
|
it("cache public", function (done) {
|
|
99
99
|
const middleware = cache.public(ttl);
|
|
100
|
-
expect(middleware).to.not.null
|
|
100
|
+
expect(middleware).to.not.be.null;
|
|
101
101
|
expect(middleware).to.be.a("function");
|
|
102
102
|
runMiddleware(middleware, function (res) {
|
|
103
103
|
const cacheControl = res.get("Cache-Control");
|
|
104
|
-
expect(cacheControl).to.not.null
|
|
104
|
+
expect(cacheControl).to.not.be.null;
|
|
105
105
|
expect(cacheControl.indexOf("public")).to.equal(0);
|
|
106
106
|
|
|
107
107
|
const controls = parseCacheControl(cacheControl);
|
|
@@ -113,11 +113,11 @@ describe("Cache Middleware", function () {
|
|
|
113
113
|
|
|
114
114
|
it("cache public, with custom options", function (done) {
|
|
115
115
|
const middleware = cache.public(ttl, { mustRevalidate: true });
|
|
116
|
-
expect(middleware).to.not.null
|
|
116
|
+
expect(middleware).to.not.be.null;
|
|
117
117
|
expect(middleware).to.be.a("function");
|
|
118
118
|
runMiddleware(middleware, function (res) {
|
|
119
119
|
const cacheControl = res.get("Cache-Control");
|
|
120
|
-
expect(cacheControl).to.not.null
|
|
120
|
+
expect(cacheControl).to.not.be.null;
|
|
121
121
|
expect(cacheControl.indexOf("public")).to.equal(0);
|
|
122
122
|
|
|
123
123
|
const controls = parseCacheControl(cacheControl);
|
|
@@ -137,11 +137,11 @@ describe("Cache Middleware", function () {
|
|
|
137
137
|
proxyRevalidate: true,
|
|
138
138
|
noTransform: true,
|
|
139
139
|
});
|
|
140
|
-
expect(middleware).to.not.null
|
|
140
|
+
expect(middleware).to.not.be.null;
|
|
141
141
|
expect(middleware).to.be.a("function");
|
|
142
142
|
runMiddleware(middleware, function (res) {
|
|
143
143
|
const cacheControl = res.get("Cache-Control");
|
|
144
|
-
expect(cacheControl).to.not.null
|
|
144
|
+
expect(cacheControl).to.not.be.null;
|
|
145
145
|
expect(cacheControl.indexOf("public")).to.equal(0);
|
|
146
146
|
|
|
147
147
|
const controls = parseCacheControl(cacheControl);
|