@aomex/etag 0.0.1 → 0.0.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.
- package/CHANGELOG.md +18 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @aomex/etag
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`d8debb9`](https://github.com/aomex/aomex/commit/d8debb9b6319d30e48cb77d97103b5559c57789c) Thanks [@geekact](https://github.com/geekact)! - refactor(web): response 的 header 均使用首字母大写的格式
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`d8debb9`](https://github.com/aomex/aomex/commit/d8debb9b6319d30e48cb77d97103b5559c57789c), [`64c10e1`](https://github.com/aomex/aomex/commit/64c10e17ff92251bb2d9f45e0bddde5cba8a3b20), [`6a57463`](https://github.com/aomex/aomex/commit/6a57463c1107c38a8b8cf5fa00ff3289bf629c0a), [`8857115`](https://github.com/aomex/aomex/commit/88571153b7e84ec6d66d37970c3ef7b4e1924a03), [`68b1365`](https://github.com/aomex/aomex/commit/68b13655922a0714bcdd2101ce659da382d44e8b), [`b51a81a`](https://github.com/aomex/aomex/commit/b51a81a65313073dff5307b310b6656da2ad5186), [`ee021e3`](https://github.com/aomex/aomex/commit/ee021e342814f12777e538c06a19971e1020f201), [`b5aaec5`](https://github.com/aomex/aomex/commit/b5aaec540e3d732868a270a969a94ccd6ff9ac6a), [`fd6ae40`](https://github.com/aomex/aomex/commit/fd6ae40577bd9a62c211d4615483fc5dd58f5865)]:
|
|
10
|
+
- @aomex/web@0.0.5
|
|
11
|
+
- @aomex/core@0.0.4
|
|
12
|
+
|
|
13
|
+
## 0.0.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`121253a`](https://github.com/aomex/aomex/commit/121253a6fc203e427bfd25e82d713bec6ac13b38), [`59dc183`](https://github.com/aomex/aomex/commit/59dc183bcec9b7221c18865563b38cba5d82869b), [`8cb74fd`](https://github.com/aomex/aomex/commit/8cb74fdd27626037aa9bc80cb2930e4f0d67f8e6), [`d834392`](https://github.com/aomex/aomex/commit/d834392b1e0f6333d66d11378d9f4ceb813a58a9), [`91feda4`](https://github.com/aomex/aomex/commit/91feda457dfa8bd8dd2c8f38bfaaf4f7f2f7702f)]:
|
|
18
|
+
- @aomex/web@0.0.4
|
|
19
|
+
- @aomex/core@0.0.3
|
|
20
|
+
|
|
3
21
|
## 0.0.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var etag = (options = {}) => {
|
|
|
8
8
|
await next();
|
|
9
9
|
const { response, request } = ctx;
|
|
10
10
|
const { body } = response;
|
|
11
|
-
if (body === null || response.hasHeader("
|
|
11
|
+
if (body === null || response.hasHeader("Etag"))
|
|
12
12
|
return;
|
|
13
13
|
if (response.statusCode < 200 || response.statusCode > 299)
|
|
14
14
|
return;
|
|
@@ -21,7 +21,7 @@ var etag = (options = {}) => {
|
|
|
21
21
|
entity = JSON.stringify(body);
|
|
22
22
|
}
|
|
23
23
|
if (entity) {
|
|
24
|
-
response.setHeader("
|
|
24
|
+
response.setHeader("Etag", calculate(entity, options));
|
|
25
25
|
}
|
|
26
26
|
if (request.fresh) {
|
|
27
27
|
ctx.send(304, null);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ReadStream } from 'node:fs';\nimport { stat } from 'node:fs/promises';\nimport calculate from 'etag';\nimport { middleware } from '@aomex/core';\nimport type { WebMiddleware } from '@aomex/web';\n\nexport const etag = (options: calculate.Options = {}): WebMiddleware => {\n return middleware.web(async (ctx, next) => {\n await next();\n\n const { response, request } = ctx;\n const { body } = response;\n\n if (body === null || response.hasHeader('
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ReadStream } from 'node:fs';\nimport { stat } from 'node:fs/promises';\nimport calculate from 'etag';\nimport { middleware } from '@aomex/core';\nimport type { WebMiddleware } from '@aomex/web';\n\nexport const etag = (options: calculate.Options = {}): WebMiddleware => {\n return middleware.web(async (ctx, next) => {\n await next();\n\n const { response, request } = ctx;\n const { body } = response;\n\n if (body === null || response.hasHeader('Etag')) return;\n if (response.statusCode < 200 || response.statusCode > 299) return;\n\n let entity: Parameters<typeof calculate>[0];\n if (body instanceof ReadStream) {\n entity = await stat(body.path);\n } else if (typeof body === 'string' || Buffer.isBuffer(body)) {\n entity = body;\n } else {\n entity = JSON.stringify(body);\n }\n\n if (entity) {\n response.setHeader('Etag', calculate(entity, options));\n }\n\n if (request.fresh) {\n ctx.send(304, null);\n }\n });\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,OAAO,eAAe;AACtB,SAAS,kBAAkB;AAGpB,IAAM,OAAO,CAAC,UAA6B,CAAC,MAAqB;AACtE,SAAO,WAAW,IAAI,OAAO,KAAK,SAAS;AACzC,UAAM,KAAK;AAEX,UAAM,EAAE,UAAU,QAAQ,IAAI;AAC9B,UAAM,EAAE,KAAK,IAAI;AAEjB,QAAI,SAAS,QAAQ,SAAS,UAAU,MAAM;AAAG;AACjD,QAAI,SAAS,aAAa,OAAO,SAAS,aAAa;AAAK;AAE5D,QAAI;AACJ,QAAI,gBAAgB,YAAY;AAC9B,eAAS,MAAM,KAAK,KAAK,IAAI;AAAA,IAC/B,WAAW,OAAO,SAAS,YAAY,OAAO,SAAS,IAAI,GAAG;AAC5D,eAAS;AAAA,IACX,OAAO;AACL,eAAS,KAAK,UAAU,IAAI;AAAA,IAC9B;AAEA,QAAI,QAAQ;AACV,eAAS,UAAU,QAAQ,UAAU,QAAQ,OAAO,CAAC;AAAA,IACvD;AAEA,QAAI,QAAQ,OAAO;AACjB,UAAI,KAAK,KAAK,IAAI;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aomex/etag",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "响应缓存标志",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"etag"
|
|
@@ -29,19 +29,16 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@aomex/core": "^0.0.
|
|
33
|
-
"@aomex/web": "^0.0.
|
|
32
|
+
"@aomex/core": "^0.0.4",
|
|
33
|
+
"@aomex/web": "^0.0.5"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"etag": "^1.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@aomex/core": "^0.0.
|
|
40
|
-
"@aomex/web": "^0.0.
|
|
41
|
-
"@types/etag": "^1.8.1"
|
|
42
|
-
"@types/supertest": "^2.0.12",
|
|
43
|
-
"supertest": "^6.2.4",
|
|
44
|
-
"vitest": "^0.28.4"
|
|
39
|
+
"@aomex/core": "^0.0.4",
|
|
40
|
+
"@aomex/web": "^0.0.5",
|
|
41
|
+
"@types/etag": "^1.8.1"
|
|
45
42
|
},
|
|
46
43
|
"scripts": {}
|
|
47
44
|
}
|