vafast 0.1.3 → 0.1.4
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.js +12 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55530,23 +55530,21 @@ var defaultValidationErrorHandler = (error, field, value, schema) => {
|
|
|
55530
55530
|
timestamp: new Date().toISOString()
|
|
55531
55531
|
}, 400);
|
|
55532
55532
|
};
|
|
55533
|
-
|
|
55533
|
+
var TEXT_HEADERS = { "Content-Type": "text/plain; charset=utf-8" };
|
|
55534
|
+
var EMPTY_RESPONSE_204 = new Response(null, { status: 204 });
|
|
55535
|
+
function autoResponseUltra(result) {
|
|
55534
55536
|
if (result instanceof Response) {
|
|
55535
55537
|
return result;
|
|
55536
55538
|
}
|
|
55537
55539
|
if (result === null || result === undefined) {
|
|
55538
|
-
return
|
|
55540
|
+
return EMPTY_RESPONSE_204;
|
|
55539
55541
|
}
|
|
55540
55542
|
switch (typeof result) {
|
|
55541
55543
|
case "string":
|
|
55542
|
-
return new Response(result, {
|
|
55543
|
-
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
55544
|
-
});
|
|
55544
|
+
return new Response(result, { headers: TEXT_HEADERS });
|
|
55545
55545
|
case "number":
|
|
55546
55546
|
case "boolean":
|
|
55547
|
-
return new Response(
|
|
55548
|
-
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
55549
|
-
});
|
|
55547
|
+
return new Response(result.toString(), { headers: TEXT_HEADERS });
|
|
55550
55548
|
case "object":
|
|
55551
55549
|
if ("data" in result) {
|
|
55552
55550
|
const { data, status = 200, headers = {} } = result;
|
|
@@ -55561,13 +55559,16 @@ function autoResponse(result) {
|
|
|
55561
55559
|
"Content-Type": "text/plain; charset=utf-8",
|
|
55562
55560
|
...headers
|
|
55563
55561
|
};
|
|
55564
|
-
return new Response(
|
|
55562
|
+
return new Response(data.toString(), {
|
|
55563
|
+
status,
|
|
55564
|
+
headers: finalHeaders
|
|
55565
|
+
});
|
|
55565
55566
|
}
|
|
55566
55567
|
return json(data, status, headers);
|
|
55567
55568
|
}
|
|
55568
55569
|
return json(result);
|
|
55569
55570
|
default:
|
|
55570
|
-
return
|
|
55571
|
+
return EMPTY_RESPONSE_204;
|
|
55571
55572
|
}
|
|
55572
55573
|
}
|
|
55573
55574
|
function createRouteHandler(config, handler) {
|
|
@@ -55617,7 +55618,7 @@ function createRouteHandler(config, handler) {
|
|
|
55617
55618
|
cookies,
|
|
55618
55619
|
...extras
|
|
55619
55620
|
});
|
|
55620
|
-
return
|
|
55621
|
+
return autoResponseUltra(result);
|
|
55621
55622
|
} catch (error) {
|
|
55622
55623
|
if (error instanceof Error && error.message.includes("\u9A8C\u8BC1\u5931\u8D25")) {
|
|
55623
55624
|
const field = extractFieldFromError(error);
|