bun-plugin-stx 0.2.873 → 0.2.875
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/serve.d.ts +12 -0
- package/dist/serve.js +12 -0
- package/package.json +3 -3
package/dist/serve.d.ts
CHANGED
|
@@ -29,6 +29,18 @@ export declare function fillRouteParams(html: string, params: Record<string, str
|
|
|
29
29
|
* cache, never correctness.
|
|
30
30
|
*/
|
|
31
31
|
export declare function serverScriptsReadParams(serverScripts: string[], paramNames: string[]): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The answer to a request whose URL cannot be parsed, or null for any other.
|
|
34
|
+
*
|
|
35
|
+
* Bun builds `req.url` from the request line and the Host header. A request
|
|
36
|
+
* with no usable host (a scanner sending `Host:` empty, or raw bytes) arrives
|
|
37
|
+
* with a bare path such as `/`, and the first `new URL(req.url)` in the
|
|
38
|
+
* handler throws. That was logged as "[stx] Request failed" with a stack and
|
|
39
|
+
* answered 500, as if the server had broken, when the request was simply
|
|
40
|
+
* malformed. It is the client's error and gets a 400, without a log line an
|
|
41
|
+
* operator would chase.
|
|
42
|
+
*/
|
|
43
|
+
export declare function malformedRequestResponse(req: Pick<Request, 'url'>): Response | null;
|
|
32
44
|
/**
|
|
33
45
|
* A token to mint for this request, or null to leave it alone.
|
|
34
46
|
*
|
package/dist/serve.js
CHANGED
|
@@ -9391,6 +9391,14 @@ function serverScriptsReadParams(serverScripts, paramNames) {
|
|
|
9391
9391
|
return serverScripts.some((script) => pattern.test(script));
|
|
9392
9392
|
}
|
|
9393
9393
|
var CSRF_COOKIE = "X-CSRF-Token";
|
|
9394
|
+
function malformedRequestResponse(req) {
|
|
9395
|
+
if (URL.canParse(req.url))
|
|
9396
|
+
return null;
|
|
9397
|
+
return new Response("Bad Request", {
|
|
9398
|
+
status: 400,
|
|
9399
|
+
headers: { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "no-store" }
|
|
9400
|
+
});
|
|
9401
|
+
}
|
|
9394
9402
|
function csrfTokenToMint(req, cookies) {
|
|
9395
9403
|
const method = (req.method || "GET").toUpperCase();
|
|
9396
9404
|
if (method !== "GET" && method !== "HEAD")
|
|
@@ -11251,6 +11259,9 @@ ${output}`;
|
|
|
11251
11259
|
});
|
|
11252
11260
|
},
|
|
11253
11261
|
async fetch(req, server) {
|
|
11262
|
+
const malformed = malformedRequestResponse(req);
|
|
11263
|
+
if (malformed)
|
|
11264
|
+
return malformed;
|
|
11254
11265
|
const warmup = awaitImageWarmup();
|
|
11255
11266
|
if (warmup)
|
|
11256
11267
|
await warmup;
|
|
@@ -12248,6 +12259,7 @@ export {
|
|
|
12248
12259
|
isRenderFailure,
|
|
12249
12260
|
isRenderableCacheCandidate,
|
|
12250
12261
|
isStaticAssetPath,
|
|
12262
|
+
malformedRequestResponse,
|
|
12251
12263
|
matchDomain,
|
|
12252
12264
|
orderDynamicRouteFiles,
|
|
12253
12265
|
pageExcluder,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-plugin-stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.875",
|
|
5
5
|
"description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typecheck": "bun tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@stacksjs/stx": "0.2.
|
|
78
|
-
"stx-router": "0.2.
|
|
77
|
+
"@stacksjs/stx": "0.2.875",
|
|
78
|
+
"stx-router": "0.2.875"
|
|
79
79
|
}
|
|
80
80
|
}
|