@easydocs/express 0.5.0 → 0.5.4
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/{LICENSE.md → LICENSE} +5 -5
- 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/{LICENSE.md → LICENSE}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Ruben González Alonso
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
copies or substantial portions of the Software.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
SOFTWARE.
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
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.4",
|
|
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.4"
|
|
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",
|