@easydocs/express 0.5.0 → 0.5.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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +9 -3
package/dist/index.cjs
CHANGED
|
@@ -26,11 +26,12 @@ module.exports = __toCommonJS(index_exports);
|
|
|
26
26
|
var import_core = require("@easydocs/core");
|
|
27
27
|
function easydocs(config) {
|
|
28
28
|
const parsedConfig = (0, import_core.parseConfig)(config);
|
|
29
|
+
const capturer = (0, import_core.createCapturer)(parsedConfig);
|
|
29
30
|
return function easydocsMiddleware(req, res, next) {
|
|
30
31
|
const startedAt = Date.now();
|
|
31
32
|
const originalJson = res.json.bind(res);
|
|
32
33
|
res.json = function(body) {
|
|
33
|
-
|
|
34
|
+
capturer.capture(
|
|
34
35
|
(0, import_core.buildCaptureEvent)({
|
|
35
36
|
method: req.method,
|
|
36
37
|
path: req.route?.path ?? req.path,
|
|
@@ -42,8 +43,7 @@ function easydocs(config) {
|
|
|
42
43
|
requestHeaders: req.headers,
|
|
43
44
|
responseHeaders: res.getHeaders(),
|
|
44
45
|
durationMs: Date.now() - startedAt
|
|
45
|
-
})
|
|
46
|
-
parsedConfig
|
|
46
|
+
})
|
|
47
47
|
);
|
|
48
48
|
return originalJson(body);
|
|
49
49
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createCapturer, parseConfig, buildCaptureEvent } from '@easydocs/core'\nimport type { EasyDocsConfig } from '@easydocs/core'\nimport type { Request, Response, NextFunction } from 'express'\n\nexport function easydocs(config?: EasyDocsConfig) {\n const parsedConfig = parseConfig(config)\n const capturer = createCapturer(parsedConfig)\n return function easydocsMiddleware(req: Request, res: Response, next: NextFunction) {\n const startedAt = Date.now()\n const originalJson = res.json.bind(res)\n\n res.json = function (body: unknown) {\n capturer.capture(\n buildCaptureEvent({\n method: req.method,\n path: req.route?.path ?? req.path,\n query: req.query as Record<string, unknown>,\n params: req.params,\n requestBody: req.body,\n responseBody: body,\n status: res.statusCode,\n requestHeaders: req.headers as Record<string, unknown>,\n responseHeaders: res.getHeaders() as Record<string, unknown>,\n durationMs: Date.now() - startedAt,\n })\n )\n return originalJson(body)\n }\n\n next()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+D;AAIxD,SAAS,SAAS,QAAyB;AAChD,QAAM,mBAAe,yBAAY,MAAM;AACvC,QAAM,eAAW,4BAAe,YAAY;AAC5C,SAAO,SAAS,mBAAmB,KAAc,KAAe,MAAoB;AAClF,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,eAAe,IAAI,KAAK,KAAK,GAAG;AAEtC,QAAI,OAAO,SAAU,MAAe;AAClC,eAAS;AAAA,YACP,+BAAkB;AAAA,UAChB,QAAQ,IAAI;AAAA,UACZ,MAAM,IAAI,OAAO,QAAQ,IAAI;AAAA,UAC7B,OAAO,IAAI;AAAA,UACX,QAAQ,IAAI;AAAA,UACZ,aAAa,IAAI;AAAA,UACjB,cAAc;AAAA,UACd,QAAQ,IAAI;AAAA,UACZ,gBAAgB,IAAI;AAAA,UACpB,iBAAiB,IAAI,WAAW;AAAA,UAChC,YAAY,KAAK,IAAI,IAAI;AAAA,QAC3B,CAAC;AAAA,MACH;AACA,aAAO,aAAa,IAAI;AAAA,IAC1B;AAEA,SAAK;AAAA,EACP;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import { createCapturer, parseConfig, buildCaptureEvent } from "@easydocs/core";
|
|
3
3
|
function easydocs(config) {
|
|
4
4
|
const parsedConfig = parseConfig(config);
|
|
5
|
+
const capturer = createCapturer(parsedConfig);
|
|
5
6
|
return function easydocsMiddleware(req, res, next) {
|
|
6
7
|
const startedAt = Date.now();
|
|
7
8
|
const originalJson = res.json.bind(res);
|
|
8
9
|
res.json = function(body) {
|
|
9
|
-
capture(
|
|
10
|
+
capturer.capture(
|
|
10
11
|
buildCaptureEvent({
|
|
11
12
|
method: req.method,
|
|
12
13
|
path: req.route?.path ?? req.path,
|
|
@@ -18,8 +19,7 @@ function easydocs(config) {
|
|
|
18
19
|
requestHeaders: req.headers,
|
|
19
20
|
responseHeaders: res.getHeaders(),
|
|
20
21
|
durationMs: Date.now() - startedAt
|
|
21
|
-
})
|
|
22
|
-
parsedConfig
|
|
22
|
+
})
|
|
23
23
|
);
|
|
24
24
|
return originalJson(body);
|
|
25
25
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createCapturer, parseConfig, buildCaptureEvent } from '@easydocs/core'\nimport type { EasyDocsConfig } from '@easydocs/core'\nimport type { Request, Response, NextFunction } from 'express'\n\nexport function easydocs(config?: EasyDocsConfig) {\n const parsedConfig = parseConfig(config)\n const capturer = createCapturer(parsedConfig)\n return function easydocsMiddleware(req: Request, res: Response, next: NextFunction) {\n const startedAt = Date.now()\n const originalJson = res.json.bind(res)\n\n res.json = function (body: unknown) {\n capturer.capture(\n buildCaptureEvent({\n method: req.method,\n path: req.route?.path ?? req.path,\n query: req.query as Record<string, unknown>,\n params: req.params,\n requestBody: req.body,\n responseBody: body,\n status: res.statusCode,\n requestHeaders: req.headers as Record<string, unknown>,\n responseHeaders: res.getHeaders() as Record<string, unknown>,\n durationMs: Date.now() - startedAt,\n })\n )\n return originalJson(body)\n }\n\n next()\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB,aAAa,yBAAyB;AAIxD,SAAS,SAAS,QAAyB;AAChD,QAAM,eAAe,YAAY,MAAM;AACvC,QAAM,WAAW,eAAe,YAAY;AAC5C,SAAO,SAAS,mBAAmB,KAAc,KAAe,MAAoB;AAClF,UAAM,YAAY,KAAK,IAAI;AAC3B,UAAM,eAAe,IAAI,KAAK,KAAK,GAAG;AAEtC,QAAI,OAAO,SAAU,MAAe;AAClC,eAAS;AAAA,QACP,kBAAkB;AAAA,UAChB,QAAQ,IAAI;AAAA,UACZ,MAAM,IAAI,OAAO,QAAQ,IAAI;AAAA,UAC7B,OAAO,IAAI;AAAA,UACX,QAAQ,IAAI;AAAA,UACZ,aAAa,IAAI;AAAA,UACjB,cAAc;AAAA,UACd,QAAQ,IAAI;AAAA,UACZ,gBAAgB,IAAI;AAAA,UACpB,iBAAiB,IAAI,WAAW;AAAA,UAChC,YAAY,KAAK,IAAI,IAAI;AAAA,QAC3B,CAAC;AAAA,MACH;AACA,aAAO,aAAa,IAAI;AAAA,IAC1B;AAEA,SAAK;AAAA,EACP;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easydocs/express",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"README.md"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@easydocs/core": "0.5.
|
|
21
|
+
"@easydocs/core": "0.5.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"express": ">=4.0.0"
|
|
@@ -30,7 +30,13 @@
|
|
|
30
30
|
"supertest": "^7.2.2",
|
|
31
31
|
"tsup": "^8.3.0",
|
|
32
32
|
"typescript": "^5",
|
|
33
|
-
"
|
|
33
|
+
"vite": "8.0.13",
|
|
34
|
+
"vitest": "^4.1.6"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/RubenGlez/easydocs",
|
|
39
|
+
"directory": ""
|
|
34
40
|
},
|
|
35
41
|
"scripts": {
|
|
36
42
|
"build": "tsup",
|