@twin.org/api-processors 0.0.2-next.7 → 0.0.2-next.9
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/cjs/index.cjs +14 -7
- package/dist/esm/index.mjs +14 -7
- package/docs/changelog.md +28 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -80,7 +80,7 @@ class RestRouteProcessor {
|
|
|
80
80
|
// instead of the default application/json
|
|
81
81
|
headers[web.HeaderTypes.ContentType] =
|
|
82
82
|
restRouteResponse?.attachment?.mimeType ??
|
|
83
|
-
|
|
83
|
+
restRouteResponse.headers?.[web.HeaderTypes.ContentType] ??
|
|
84
84
|
`${web.MimeTypes.Json}; charset=utf-8`;
|
|
85
85
|
// If there are filename or inline options set then add the content disposition
|
|
86
86
|
if (core.Is.stringValue(restRouteResponse?.attachment?.filename) ||
|
|
@@ -353,9 +353,7 @@ class LoggingProcessor {
|
|
|
353
353
|
const now = process.hrtime.bigint();
|
|
354
354
|
processorState.requestStart = now;
|
|
355
355
|
const contentType = request.headers?.[web.HeaderTypes.ContentType];
|
|
356
|
-
const isJson =
|
|
357
|
-
? contentType.includes(web.MimeTypes.Json) || contentType.includes(web.MimeTypes.JsonLd)
|
|
358
|
-
: false;
|
|
356
|
+
const isJson = this.isMimeJson(contentType);
|
|
359
357
|
let requestUrl = "";
|
|
360
358
|
if (core.Is.stringValue(request.url)) {
|
|
361
359
|
// Socket paths do not have a prefix so just use the whole url.
|
|
@@ -388,9 +386,7 @@ class LoggingProcessor {
|
|
|
388
386
|
let data;
|
|
389
387
|
if (this._includeBody) {
|
|
390
388
|
const contentType = response.headers?.[web.HeaderTypes.ContentType];
|
|
391
|
-
const isJson =
|
|
392
|
-
? contentType.includes(web.MimeTypes.Json) || contentType.includes(web.MimeTypes.JsonLd)
|
|
393
|
-
: false;
|
|
389
|
+
const isJson = this.isMimeJson(contentType);
|
|
394
390
|
const contentLength = response.headers?.[web.HeaderTypes.ContentLength];
|
|
395
391
|
if (isJson) {
|
|
396
392
|
data = {
|
|
@@ -462,6 +458,17 @@ class LoggingProcessor {
|
|
|
462
458
|
}
|
|
463
459
|
return propValue;
|
|
464
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Check if the content type is JSON.
|
|
463
|
+
* @param contentType The content type to check.
|
|
464
|
+
* @returns True if the content type is JSON, false otherwise.
|
|
465
|
+
* @internal
|
|
466
|
+
*/
|
|
467
|
+
isMimeJson(contentType) {
|
|
468
|
+
return core.Is.stringValue(contentType)
|
|
469
|
+
? contentType.includes(web.MimeTypes.Json) || contentType.includes(web.MimeTypes.JsonLd)
|
|
470
|
+
: false;
|
|
471
|
+
}
|
|
465
472
|
}
|
|
466
473
|
|
|
467
474
|
/**
|
package/dist/esm/index.mjs
CHANGED
|
@@ -78,7 +78,7 @@ class RestRouteProcessor {
|
|
|
78
78
|
// instead of the default application/json
|
|
79
79
|
headers[HeaderTypes.ContentType] =
|
|
80
80
|
restRouteResponse?.attachment?.mimeType ??
|
|
81
|
-
|
|
81
|
+
restRouteResponse.headers?.[HeaderTypes.ContentType] ??
|
|
82
82
|
`${MimeTypes.Json}; charset=utf-8`;
|
|
83
83
|
// If there are filename or inline options set then add the content disposition
|
|
84
84
|
if (Is.stringValue(restRouteResponse?.attachment?.filename) ||
|
|
@@ -351,9 +351,7 @@ class LoggingProcessor {
|
|
|
351
351
|
const now = process.hrtime.bigint();
|
|
352
352
|
processorState.requestStart = now;
|
|
353
353
|
const contentType = request.headers?.[HeaderTypes.ContentType];
|
|
354
|
-
const isJson =
|
|
355
|
-
? contentType.includes(MimeTypes.Json) || contentType.includes(MimeTypes.JsonLd)
|
|
356
|
-
: false;
|
|
354
|
+
const isJson = this.isMimeJson(contentType);
|
|
357
355
|
let requestUrl = "";
|
|
358
356
|
if (Is.stringValue(request.url)) {
|
|
359
357
|
// Socket paths do not have a prefix so just use the whole url.
|
|
@@ -386,9 +384,7 @@ class LoggingProcessor {
|
|
|
386
384
|
let data;
|
|
387
385
|
if (this._includeBody) {
|
|
388
386
|
const contentType = response.headers?.[HeaderTypes.ContentType];
|
|
389
|
-
const isJson =
|
|
390
|
-
? contentType.includes(MimeTypes.Json) || contentType.includes(MimeTypes.JsonLd)
|
|
391
|
-
: false;
|
|
387
|
+
const isJson = this.isMimeJson(contentType);
|
|
392
388
|
const contentLength = response.headers?.[HeaderTypes.ContentLength];
|
|
393
389
|
if (isJson) {
|
|
394
390
|
data = {
|
|
@@ -460,6 +456,17 @@ class LoggingProcessor {
|
|
|
460
456
|
}
|
|
461
457
|
return propValue;
|
|
462
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Check if the content type is JSON.
|
|
461
|
+
* @param contentType The content type to check.
|
|
462
|
+
* @returns True if the content type is JSON, false otherwise.
|
|
463
|
+
* @internal
|
|
464
|
+
*/
|
|
465
|
+
isMimeJson(contentType) {
|
|
466
|
+
return Is.stringValue(contentType)
|
|
467
|
+
? contentType.includes(MimeTypes.Json) || contentType.includes(MimeTypes.JsonLd)
|
|
468
|
+
: false;
|
|
469
|
+
}
|
|
463
470
|
}
|
|
464
471
|
|
|
465
472
|
/**
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/api-processors - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.9](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.8...api-processors-v0.0.2-next.9) (2025-08-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/api-models bumped from 0.0.2-next.8 to 0.0.2-next.9
|
|
16
|
+
|
|
17
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.7...api-processors-v0.0.2-next.8) (2025-08-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/api-models bumped from 0.0.2-next.7 to 0.0.2-next.8
|
|
30
|
+
|
|
3
31
|
## [0.0.2-next.7](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.6...api-processors-v0.0.2-next.7) (2025-08-20)
|
|
4
32
|
|
|
5
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-processors",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.9",
|
|
4
4
|
"description": "Route processors for use with API servers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/api-models": "0.0.2-next.
|
|
17
|
+
"@twin.org/api-models": "0.0.2-next.9",
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
19
|
"@twin.org/logging-models": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|