spooder 6.2.4 → 6.2.5
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/bun.lock +3 -3
- package/package.json +1 -1
- package/src/api.ts +9 -2
package/bun.lock
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
"packages": {
|
|
13
|
-
"@types/bun": ["@types/bun@1.3.
|
|
13
|
+
"@types/bun": ["@types/bun@1.3.8", "", { "dependencies": { "bun-types": "1.3.8" } }, "sha512-3LvWJ2q5GerAXYxO2mffLTqOzEu5qnhEAlh48Vnu8WQfnmSwbgagjGZV6BoHKJztENYEDn6QmVd949W4uESRJA=="],
|
|
14
14
|
|
|
15
|
-
"@types/node": ["@types/node@25.0
|
|
15
|
+
"@types/node": ["@types/node@25.2.0", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-DZ8VwRFUNzuqJ5khrvwMXHmvPe+zGayJhr2CDNiKB1WBE1ST8Djl00D0IC4vvNmHMdj6DlbYRIaFE7WHjlDl5w=="],
|
|
16
16
|
|
|
17
|
-
"bun-types": ["bun-types@1.3.
|
|
17
|
+
"bun-types": ["bun-types@1.3.8", "", { "dependencies": { "@types/node": "*" } }, "sha512-fL99nxdOWvV4LqjmC+8Q9kW3M4QTtTR1eePs94v5ctGqU8OeceWrSUaRw3JYb7tU3FkMIAjkueehrHPPPGKi5Q=="],
|
|
18
18
|
|
|
19
19
|
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
|
20
20
|
}
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -1904,10 +1904,17 @@ export function http_serve(port: number, hostname?: string) {
|
|
|
1904
1904
|
});
|
|
1905
1905
|
}
|
|
1906
1906
|
|
|
1907
|
+
const wrap_response = (result: ReturnType<typeof handler>) => {
|
|
1908
|
+
if (result !== null && typeof result === 'object' && !(result instanceof Response) && !(result instanceof Blob))
|
|
1909
|
+
return Response.json(result, { headers: { 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Pragma': 'no-cache' } });
|
|
1910
|
+
|
|
1911
|
+
return result;
|
|
1912
|
+
};
|
|
1913
|
+
|
|
1907
1914
|
try {
|
|
1908
1915
|
// GET/HEAD requests don't have bodies, skip validation
|
|
1909
1916
|
if (req.method === 'GET' || req.method === 'HEAD')
|
|
1910
|
-
return handler(req, url, null);
|
|
1917
|
+
return wrap_response(await handler(req, url, null));
|
|
1911
1918
|
|
|
1912
1919
|
if (req.headers.get('Content-Type') !== 'application/json')
|
|
1913
1920
|
return 400; // Bad Request
|
|
@@ -1916,7 +1923,7 @@ export function http_serve(port: number, hostname?: string) {
|
|
|
1916
1923
|
if (json === null || typeof json !== 'object' || Array.isArray(json))
|
|
1917
1924
|
return 400; // Bad Request
|
|
1918
1925
|
|
|
1919
|
-
return handler(req, url, json as JsonObject);
|
|
1926
|
+
return wrap_response(await handler(req, url, json as JsonObject));
|
|
1920
1927
|
} catch (e) {
|
|
1921
1928
|
return 400; // Bad Request
|
|
1922
1929
|
}
|