@fedify/koa 2.5.0-dev.2378 → 2.5.0-dev.2420
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 +18 -0
- package/dist/index.js +18 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ function createMiddleware(federation, contextDataFactory) {
|
|
|
32
32
|
notAcceptable = true;
|
|
33
33
|
body?.restore();
|
|
34
34
|
await next();
|
|
35
|
+
setNotAcceptableResponse(ctx);
|
|
35
36
|
return new Response("Not acceptable", {
|
|
36
37
|
status: 406,
|
|
37
38
|
headers: {
|
|
@@ -154,5 +155,22 @@ function setResponse(ctx, response) {
|
|
|
154
155
|
} else this.push(value);
|
|
155
156
|
} });
|
|
156
157
|
}
|
|
158
|
+
function setNotAcceptableResponse(ctx) {
|
|
159
|
+
if (ctx.status === 404 && ctx.body === void 0 && ctx.message === "Not Found" && !ctx.response._explicitStatus && !ctx.headerSent && ctx.writable && ctx.respond !== false) {
|
|
160
|
+
for (const header of [
|
|
161
|
+
"Content-Encoding",
|
|
162
|
+
"Content-Language",
|
|
163
|
+
"Content-Range",
|
|
164
|
+
"ETag",
|
|
165
|
+
"Last-Modified",
|
|
166
|
+
"Transfer-Encoding",
|
|
167
|
+
"Content-Length"
|
|
168
|
+
]) ctx.remove(header);
|
|
169
|
+
ctx.status = 406;
|
|
170
|
+
ctx.body = "Not acceptable";
|
|
171
|
+
ctx.set("Content-Type", "text/plain; charset=utf-8");
|
|
172
|
+
ctx.vary("Accept");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
157
175
|
//#endregion
|
|
158
176
|
exports.createMiddleware = createMiddleware;
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ function createMiddleware(federation, contextDataFactory) {
|
|
|
31
31
|
notAcceptable = true;
|
|
32
32
|
body?.restore();
|
|
33
33
|
await next();
|
|
34
|
+
setNotAcceptableResponse(ctx);
|
|
34
35
|
return new Response("Not acceptable", {
|
|
35
36
|
status: 406,
|
|
36
37
|
headers: {
|
|
@@ -153,5 +154,22 @@ function setResponse(ctx, response) {
|
|
|
153
154
|
} else this.push(value);
|
|
154
155
|
} });
|
|
155
156
|
}
|
|
157
|
+
function setNotAcceptableResponse(ctx) {
|
|
158
|
+
if (ctx.status === 404 && ctx.body === void 0 && ctx.message === "Not Found" && !ctx.response._explicitStatus && !ctx.headerSent && ctx.writable && ctx.respond !== false) {
|
|
159
|
+
for (const header of [
|
|
160
|
+
"Content-Encoding",
|
|
161
|
+
"Content-Language",
|
|
162
|
+
"Content-Range",
|
|
163
|
+
"ETag",
|
|
164
|
+
"Last-Modified",
|
|
165
|
+
"Transfer-Encoding",
|
|
166
|
+
"Content-Length"
|
|
167
|
+
]) ctx.remove(header);
|
|
168
|
+
ctx.status = 406;
|
|
169
|
+
ctx.body = "Not acceptable";
|
|
170
|
+
ctx.set("Content-Type", "text/plain; charset=utf-8");
|
|
171
|
+
ctx.vary("Accept");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
156
174
|
//#endregion
|
|
157
175
|
export { createMiddleware };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/koa",
|
|
3
|
-
"version": "2.5.0-dev.
|
|
3
|
+
"version": "2.5.0-dev.2420+4db1db92",
|
|
4
4
|
"description": "Integrate Fedify with Koa",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
],
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"koa": "^2.0.0 || ^3.0.0",
|
|
50
|
-
"@fedify/fedify": "^2.5.0-dev.
|
|
50
|
+
"@fedify/fedify": "^2.5.0-dev.2420+4db1db92"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/koa": "^2.15.0",
|
|
54
54
|
"@types/node": "^24.12.2",
|
|
55
55
|
"tsdown": "^0.22.0",
|
|
56
|
-
"typescript": "^6.0.0"
|
|
56
|
+
"typescript": "^6.0.0",
|
|
57
|
+
"@fedify/fixture": "2.0.0"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"build:self": "tsdown",
|