vafast 0.1.4 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +21 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51852,31 +51852,30 @@ var import_qs = __toESM(require_lib2(), 1);
51852
51852
  var import_cookie = __toESM(require_dist(), 1);
51853
51853
  async function parseBody(req) {
51854
51854
  const contentType = req.headers.get("content-type") || "";
51855
- const contentLength = req.headers.get("content-length");
51856
- const maxSize = 10 * 1024 * 1024;
51857
- if (contentLength && parseInt(contentLength) > maxSize) {
51858
- throw new Error(`\u8BF7\u6C42\u4F53\u8FC7\u5927: ${contentLength} bytes (\u6700\u5927\u5141\u8BB8: ${maxSize} bytes)`);
51859
- }
51860
- try {
51861
- if (contentType.includes("application/json")) {
51855
+ if (contentType.includes("application/json")) {
51856
+ try {
51862
51857
  return await req.json();
51858
+ } catch {
51859
+ return;
51863
51860
  }
51864
- if (contentType.includes("application/x-www-form-urlencoded")) {
51865
- const text2 = await req.text();
51866
- return Object.fromEntries(new URLSearchParams(text2));
51867
- }
51868
- if (contentType.includes("multipart/form-data")) {
51869
- return await parseMultipartFormData(req);
51870
- }
51871
- if (contentType.includes("text/plain")) {
51872
- return await req.text();
51873
- }
51874
- if (contentType.includes("application/octet-stream")) {
51875
- return await req.arrayBuffer();
51876
- }
51861
+ }
51862
+ if (contentType.includes("application/x-www-form-urlencoded")) {
51863
+ const text2 = await req.text();
51864
+ return Object.fromEntries(new URLSearchParams(text2));
51865
+ }
51866
+ if (contentType.includes("multipart/form-data")) {
51867
+ return await parseMultipartFormData(req);
51868
+ }
51869
+ if (contentType.includes("text/plain")) {
51877
51870
  return await req.text();
51878
- } catch (error) {
51879
- throw new Error(`\u89E3\u6790\u8BF7\u6C42\u4F53\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`);
51871
+ }
51872
+ if (contentType.includes("application/octet-stream")) {
51873
+ return await req.arrayBuffer();
51874
+ }
51875
+ try {
51876
+ return await req.text();
51877
+ } catch {
51878
+ return;
51880
51879
  }
51881
51880
  }
51882
51881
  async function parseMultipartFormData(req) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vafast",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "专为Bun构建的极简结构化Web框架。Go风格,函数优先。",
5
5
  "type": "module",
6
6
  "repository": {