@zeroxsolutions/server 0.4.0 → 0.5.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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## 0.5.0 (2026-09-29)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- ⚠️ **server:** read the negotiation headers, never the request body ([cf83e29](https://github.com/zeroxsolutions/zeroxsolutions/commit/cf83e29))
|
|
6
|
+
|
|
7
|
+
### ⚠️ Breaking Changes
|
|
8
|
+
|
|
9
|
+
- **server:** read the negotiation headers, never the request body ([cf83e29](https://github.com/zeroxsolutions/zeroxsolutions/commit/cf83e29))
|
|
10
|
+
jsonApiContentNegotiation no longer refuses a body sent
|
|
11
|
+
with no Content-Type or in another media type, and judges a Content-Type
|
|
12
|
+
on a bodyless request too. NEGOTIATION_RESPONSES describes the two
|
|
13
|
+
refusals that remain.
|
|
14
|
+
|
|
15
|
+
### ❤️ Thank You
|
|
16
|
+
|
|
17
|
+
- Claude Opus 5.5 (1M context)
|
|
18
|
+
- Lương Văn Tú
|
|
19
|
+
|
|
20
|
+
## 0.4.1 (2026-09-28)
|
|
21
|
+
|
|
22
|
+
This was a version bump only for @zeroxsolutions/server to align it with other projects, there were no code changes.
|
|
23
|
+
|
|
1
24
|
## 0.4.0 (2026-09-28)
|
|
2
25
|
|
|
3
26
|
### 🚀 Features
|
|
@@ -4,11 +4,9 @@ import type { SurfaceVocabulary } from './surface-vocabulary.js';
|
|
|
4
4
|
* Hono adapter over {@link negotiateJsonApi}: rejects with 415/406 per JSON:API v1.1 content
|
|
5
5
|
* negotiation, then labels a JSON:API response body with the JSON:API media type.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* a
|
|
9
|
-
*
|
|
10
|
-
* carry a body but sent no `Content-Type` reads as `''`, which the negotiator refuses (415): a wildcard never
|
|
11
|
-
* stands in for the one type this surface reads.
|
|
7
|
+
* The decision reads the two headers and never the body. A runtime decides for itself whether a bodyless
|
|
8
|
+
* request has a `body`: workerd hands every POST a stream, empty or not, so a decision keyed on the body
|
|
9
|
+
* refused every bodyless POST there while passing it under Node.
|
|
12
10
|
*
|
|
13
11
|
* The response side only labels a body `c.json` left as `application/json` (or with no `Content-Type` at all):
|
|
14
12
|
* a route that answers `c.text(...)` or `c.body(null, 204)` keeps its own header, since neither is a JSON:API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-negotiation.d.ts","sourceRoot":"","sources":["../src/content-negotiation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"content-negotiation.d.ts","sourceRoot":"","sources":["../src/content-negotiation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,iBAAiB,GAAG;IAAE,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACvE,iBAAiB,CAWnB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOxB,CAAC"}
|
|
@@ -4,11 +4,9 @@ import { errorResponse, JSON_API_MEDIA_TYPE } from '@zeroxsolutions/response';
|
|
|
4
4
|
* Hono adapter over {@link negotiateJsonApi}: rejects with 415/406 per JSON:API v1.1 content
|
|
5
5
|
* negotiation, then labels a JSON:API response body with the JSON:API media type.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* a
|
|
9
|
-
*
|
|
10
|
-
* carry a body but sent no `Content-Type` reads as `''`, which the negotiator refuses (415): a wildcard never
|
|
11
|
-
* stands in for the one type this surface reads.
|
|
7
|
+
* The decision reads the two headers and never the body. A runtime decides for itself whether a bodyless
|
|
8
|
+
* request has a `body`: workerd hands every POST a stream, empty or not, so a decision keyed on the body
|
|
9
|
+
* refused every bodyless POST there while passing it under Node.
|
|
12
10
|
*
|
|
13
11
|
* The response side only labels a body `c.json` left as `application/json` (or with no `Content-Type` at all):
|
|
14
12
|
* a route that answers `c.text(...)` or `c.body(null, 204)` keeps its own header, since neither is a JSON:API
|
|
@@ -22,9 +20,7 @@ import { errorResponse, JSON_API_MEDIA_TYPE } from '@zeroxsolutions/response';
|
|
|
22
20
|
export function jsonApiContentNegotiation(options) {
|
|
23
21
|
const supported = new Set(options.supportedExtensions ?? []);
|
|
24
22
|
return async (c, next) => {
|
|
25
|
-
|
|
26
|
-
const contentType = c.req.raw.body === null ? undefined : (c.req.header('Content-Type') ?? '');
|
|
27
|
-
const error = negotiateJsonApi(contentType, c.req.header('Accept'), options.namespace, supported);
|
|
23
|
+
const error = negotiateJsonApi(c.req.header('Content-Type'), c.req.header('Accept'), options.namespace, supported);
|
|
28
24
|
if (error)
|
|
29
25
|
throw error;
|
|
30
26
|
await next();
|
|
@@ -45,6 +41,6 @@ export function jsonApiContentNegotiation(options) {
|
|
|
45
41
|
* ```
|
|
46
42
|
*/
|
|
47
43
|
export const NEGOTIATION_RESPONSES = {
|
|
48
|
-
406: errorResponse('
|
|
49
|
-
415: errorResponse('The Content-Type header
|
|
44
|
+
406: errorResponse('Every JSON:API media type the Accept header names carries a parameter this surface does not answer'),
|
|
45
|
+
415: errorResponse('The JSON:API media type in the Content-Type header carries a parameter this surface does not read'),
|
|
50
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeroxsolutions/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"tslib": "^2.3.0",
|
|
24
|
-
"@zeroxsolutions/jsonapi": "0.
|
|
25
|
-
"@zeroxsolutions/
|
|
26
|
-
"@zeroxsolutions/
|
|
24
|
+
"@zeroxsolutions/jsonapi": "0.13.0",
|
|
25
|
+
"@zeroxsolutions/response": "0.14.2",
|
|
26
|
+
"@zeroxsolutions/query": "0.7.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@hono/zod-openapi": "^1.0.0",
|