@aomex/response-time 3.30.8-alpha.62.sha-92b25bb → 3.30.8-alpha.7326d75.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/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +16 -18
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { WebMiddleware } from "@aomex/web";
|
|
2
|
+
export declare const responseTime: () => WebMiddleware;
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { middleware } from '@aomex/common';\nimport type
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { middleware } from '@aomex/common';\nimport { type HttpError, type WebMiddleware } from '@aomex/web';\n\nconst getDelta = (start: [number, number]) => {\n const deltas = process.hrtime(start);\n return deltas[0] * 1_000 + deltas[1] / 1_000_000 + 'ms';\n};\n\n// 显式返回 WebMiddleware:避免 .d.ts 写成 import(\"@aomex/web\").WebMiddleware\nexport const responseTime = (): WebMiddleware => {\n return middleware.web((ctx, next) => {\n const start = process.hrtime();\n return next()\n .then(() => {\n ctx.response.setHeader('x-response-time', getDelta(start));\n })\n .catch((err: HttpError) => {\n err.headers = {\n ...err.headers,\n 'x-response-time': getDelta(start),\n };\n return Promise.reject(err);\n });\n });\n};\n"],"mappings":";;;AAGA,MAAM,YAAY,UAA4B;CAC5C,MAAM,SAAS,QAAQ,OAAO,KAAK;CACnC,OAAO,OAAO,KAAK,MAAQ,OAAO,KAAK,MAAY;AACrD;AAGA,MAAa,qBAAoC;CAC/C,OAAO,WAAW,KAAK,KAAK,SAAS;EACnC,MAAM,QAAQ,QAAQ,OAAO;EAC7B,OAAO,KAAK,CAAC,CACV,WAAW;GACV,IAAI,SAAS,UAAU,mBAAmB,SAAS,KAAK,CAAC;EAC3D,CAAC,CAAC,CACD,OAAO,QAAmB;GACzB,IAAI,UAAU;IACZ,GAAG,IAAI;IACP,mBAAmB,SAAS,KAAK;GACnC;GACA,OAAO,QAAQ,OAAO,GAAG;EAC3B,CAAC;CACL,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aomex/response-time",
|
|
3
|
-
"version": "3.30.8-alpha.
|
|
3
|
+
"version": "3.30.8-alpha.7326d75.0",
|
|
4
4
|
"description": "计算请求接口所用时间",
|
|
5
5
|
"keywords": [],
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git@github.com:aomex/aomex.git"
|
|
9
|
+
},
|
|
7
10
|
"homepage": "https://aomex.js.org",
|
|
8
11
|
"license": "MIT",
|
|
9
12
|
"type": "module",
|
|
10
13
|
"sideEffects": false,
|
|
11
|
-
"
|
|
12
|
-
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
13
21
|
},
|
|
14
|
-
"types": "src/index.ts",
|
|
15
|
-
"exports": "./src/index.ts",
|
|
16
22
|
"files": [
|
|
17
23
|
"dist",
|
|
18
24
|
"LICENSE",
|
|
@@ -21,14 +27,6 @@
|
|
|
21
27
|
"CHANGELOG.md"
|
|
22
28
|
],
|
|
23
29
|
"publishConfig": {
|
|
24
|
-
"types": "dist/index.d.ts",
|
|
25
|
-
"exports": {
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"import": "./dist/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./package.json": "./package.json"
|
|
31
|
-
},
|
|
32
30
|
"access": "public"
|
|
33
31
|
},
|
|
34
32
|
"peerDependencies": {
|
|
@@ -36,8 +34,8 @@
|
|
|
36
34
|
"@aomex/web": "^4.0.0"
|
|
37
35
|
},
|
|
38
36
|
"devDependencies": {
|
|
39
|
-
"@aomex/common": "3.30.8-alpha.
|
|
40
|
-
"@aomex/web": "3.30.8-alpha.
|
|
37
|
+
"@aomex/common": "3.30.8-alpha.7326d75.0",
|
|
38
|
+
"@aomex/web": "3.30.8-alpha.7326d75.0"
|
|
41
39
|
},
|
|
42
|
-
"
|
|
43
|
-
}
|
|
40
|
+
"scripts": {}
|
|
41
|
+
}
|