@mastra/deployer 1.65.0-alpha.1 → 1.65.0-alpha.2
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/server/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import process$1, { versions } from "process";
|
|
|
13
13
|
import { getMimeType } from "hono/utils/mime";
|
|
14
14
|
import { html } from "hono/html";
|
|
15
15
|
import { Tool } from "@mastra/core/tools";
|
|
16
|
-
import { MASTRA_FRAMEWORK_PUBLIC_KEY, MastraServer, applyMcpRequestAuth, checkRouteFGA, isZodError, normalizeQueryParams, redactStreamChunk, serializeStreamChunk } from "@mastra/server/server-adapter";
|
|
16
|
+
import { MASTRA_FRAMEWORK_PUBLIC_KEY, MastraServer, applyMcpRequestAuth, checkRouteFGA, getCustomHTTPExceptionResponse, isZodError, normalizeQueryParams, redactStreamChunk, serializeStreamChunk } from "@mastra/server/server-adapter";
|
|
17
17
|
import util from "util";
|
|
18
18
|
import { Buffer as Buffer$1 } from "buffer";
|
|
19
19
|
import { bodyLimit } from "hono/body-limit";
|
|
@@ -3413,21 +3413,24 @@ var MastraServer$1 = class extends MastraServer {
|
|
|
3413
3413
|
}
|
|
3414
3414
|
async registerRoute(app, route, { prefix: prefixParam } = {}) {
|
|
3415
3415
|
const prefix = prefixParam ?? this.prefix ?? "";
|
|
3416
|
-
const
|
|
3416
|
+
const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;
|
|
3417
|
+
const isBodyMethod = [
|
|
3417
3418
|
"POST",
|
|
3418
3419
|
"PUT",
|
|
3419
3420
|
"PATCH",
|
|
3420
3421
|
"DELETE"
|
|
3421
3422
|
].includes(route.method.toUpperCase());
|
|
3422
|
-
const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;
|
|
3423
3423
|
const middlewares = [];
|
|
3424
|
-
if (
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3424
|
+
if (isBodyMethod && maxSize !== void 0) middlewares.push(bodyLimit({
|
|
3425
|
+
maxSize,
|
|
3426
|
+
onError: (c) => {
|
|
3427
|
+
let errorResponse = { error: "Request body too large" };
|
|
3428
|
+
if (route.maxBodySize === void 0 && this.bodyLimitOptions) try {
|
|
3429
|
+
errorResponse = this.bodyLimitOptions.onError(errorResponse);
|
|
3430
|
+
} catch {}
|
|
3431
|
+
return c.json(errorResponse, 413);
|
|
3432
|
+
}
|
|
3433
|
+
}));
|
|
3431
3434
|
app[route.method.toLowerCase()](`${prefix}${route.path}`, ...middlewares, async (c) => {
|
|
3432
3435
|
const authResult = await this.checkRouteAuth(route, {
|
|
3433
3436
|
path: c.req.path,
|
|
@@ -3553,6 +3556,8 @@ var MastraServer$1 = class extends MastraServer {
|
|
|
3553
3556
|
path: route.path,
|
|
3554
3557
|
method: route.method
|
|
3555
3558
|
});
|
|
3559
|
+
const customResponse = getCustomHTTPExceptionResponse(error);
|
|
3560
|
+
if (customResponse) return customResponse;
|
|
3556
3561
|
if (error && typeof error === "object") {
|
|
3557
3562
|
if ("status" in error) {
|
|
3558
3563
|
const status = error.status;
|