@mastra/fastify 1.1.9 → 1.2.0-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @mastra/fastify
2
2
 
3
+ ## 1.2.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `onValidationError` hook to `ServerConfig` and `createRoute()`. When a request fails Zod schema validation (query parameters, request body, or path parameters), this hook lets you customize the error response — including the HTTP status code and response body — instead of the default 400 response. Set it on the server config to apply globally, or on individual routes to override per-route. All server adapters (Hono, Express, Fastify, Koa) support this hook. ([#13477](https://github.com/mastra-ai/mastra/pull/13477))
8
+
9
+ ```ts
10
+ const mastra = new Mastra({
11
+ server: {
12
+ onValidationError: (error, context) => ({
13
+ status: 422,
14
+ body: {
15
+ ok: false,
16
+ errors: error.issues.map(i => ({
17
+ path: i.path.join('.'),
18
+ message: i.message,
19
+ })),
20
+ source: context,
21
+ },
22
+ }),
23
+ },
24
+ });
25
+ ```
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`c2afbbc`](https://github.com/mastra-ai/mastra/commit/c2afbbccada13af07cad6742456f3f067ccd6519), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
30
+ - @mastra/core@1.11.0-alpha.0
31
+ - @mastra/server@1.11.0-alpha.0
32
+
3
33
  ## 1.1.9
4
34
 
5
35
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,217 +1,217 @@
1
1
  'use strict';
2
2
 
3
3
  var busboy = require('@fastify/busboy');
4
- var error = require('@mastra/server/handlers/error');
5
4
  var serverAdapter = require('@mastra/server/server-adapter');
6
5
 
7
6
  // src/index.ts
8
-
9
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
10
- var util;
11
- (function(util2) {
12
- util2.assertEqual = (_) => {
13
- };
14
- function assertIs(_arg) {
15
- }
16
- util2.assertIs = assertIs;
17
- function assertNever(_x) {
18
- throw new Error();
19
- }
20
- util2.assertNever = assertNever;
21
- util2.arrayToEnum = (items) => {
22
- const obj = {};
23
- for (const item of items) {
24
- obj[item] = item;
7
+ // @__NO_SIDE_EFFECTS__
8
+ function $constructor(name, initializer3, params) {
9
+ function init(inst, def) {
10
+ if (!inst._zod) {
11
+ Object.defineProperty(inst, "_zod", {
12
+ value: {
13
+ def,
14
+ constr: _,
15
+ traits: /* @__PURE__ */ new Set()
16
+ },
17
+ enumerable: false
18
+ });
25
19
  }
26
- return obj;
27
- };
28
- util2.getValidEnumValues = (obj) => {
29
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
30
- const filtered = {};
31
- for (const k of validKeys) {
32
- filtered[k] = obj[k];
20
+ if (inst._zod.traits.has(name)) {
21
+ return;
33
22
  }
34
- return util2.objectValues(filtered);
35
- };
36
- util2.objectValues = (obj) => {
37
- return util2.objectKeys(obj).map(function(e) {
38
- return obj[e];
39
- });
40
- };
41
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
42
- const keys = [];
43
- for (const key in object) {
44
- if (Object.prototype.hasOwnProperty.call(object, key)) {
45
- keys.push(key);
23
+ inst._zod.traits.add(name);
24
+ initializer3(inst, def);
25
+ const proto = _.prototype;
26
+ const keys = Object.keys(proto);
27
+ for (let i = 0; i < keys.length; i++) {
28
+ const k = keys[i];
29
+ if (!(k in inst)) {
30
+ inst[k] = proto[k].bind(inst);
46
31
  }
47
32
  }
48
- return keys;
49
- };
50
- util2.find = (arr, checker) => {
51
- for (const item of arr) {
52
- if (checker(item))
53
- return item;
33
+ }
34
+ const Parent = params?.Parent ?? Object;
35
+ class Definition extends Parent {
36
+ }
37
+ Object.defineProperty(Definition, "name", { value: name });
38
+ function _(def) {
39
+ var _a2;
40
+ const inst = params?.Parent ? new Definition() : this;
41
+ init(inst, def);
42
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
43
+ for (const fn of inst._zod.deferred) {
44
+ fn();
54
45
  }
55
- return void 0;
56
- };
57
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
58
- function joinValues(array, separator = " | ") {
59
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
46
+ return inst;
60
47
  }
61
- util2.joinValues = joinValues;
62
- util2.jsonStringifyReplacer = (_, value) => {
63
- if (typeof value === "bigint") {
64
- return value.toString();
48
+ Object.defineProperty(_, "init", { value: init });
49
+ Object.defineProperty(_, Symbol.hasInstance, {
50
+ value: (inst) => {
51
+ if (params?.Parent && inst instanceof params.Parent)
52
+ return true;
53
+ return inst?._zod?.traits?.has(name);
65
54
  }
66
- return value;
67
- };
68
- })(util || (util = {}));
69
- var objectUtil;
70
- (function(objectUtil2) {
71
- objectUtil2.mergeShapes = (first, second) => {
72
- return {
73
- ...first,
74
- ...second
75
- // second overwrites first
76
- };
77
- };
78
- })(objectUtil || (objectUtil = {}));
79
- util.arrayToEnum([
80
- "string",
81
- "nan",
82
- "number",
83
- "integer",
84
- "float",
85
- "boolean",
86
- "date",
87
- "bigint",
88
- "symbol",
89
- "function",
90
- "undefined",
91
- "null",
92
- "array",
93
- "object",
94
- "unknown",
95
- "promise",
96
- "void",
97
- "never",
98
- "map",
99
- "set"
100
- ]);
55
+ });
56
+ Object.defineProperty(_, "name", { value: name });
57
+ return _;
58
+ }
101
59
 
102
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
103
- util.arrayToEnum([
104
- "invalid_type",
105
- "invalid_literal",
106
- "custom",
107
- "invalid_union",
108
- "invalid_union_discriminator",
109
- "invalid_enum_value",
110
- "unrecognized_keys",
111
- "invalid_arguments",
112
- "invalid_return_type",
113
- "invalid_date",
114
- "invalid_string",
115
- "too_small",
116
- "too_big",
117
- "invalid_intersection_types",
118
- "not_multiple_of",
119
- "not_finite"
120
- ]);
121
- var ZodError = class _ZodError extends Error {
122
- get errors() {
123
- return this.issues;
124
- }
125
- constructor(issues) {
126
- super();
127
- this.issues = [];
128
- this.addIssue = (sub) => {
129
- this.issues = [...this.issues, sub];
130
- };
131
- this.addIssues = (subs = []) => {
132
- this.issues = [...this.issues, ...subs];
133
- };
134
- const actualProto = new.target.prototype;
135
- if (Object.setPrototypeOf) {
136
- Object.setPrototypeOf(this, actualProto);
60
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
61
+ function jsonStringifyReplacer(_, value) {
62
+ if (typeof value === "bigint")
63
+ return value.toString();
64
+ return value;
65
+ }
66
+
67
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
68
+ var initializer = (inst, def) => {
69
+ inst.name = "$ZodError";
70
+ Object.defineProperty(inst, "_zod", {
71
+ value: inst._zod,
72
+ enumerable: false
73
+ });
74
+ Object.defineProperty(inst, "issues", {
75
+ value: def,
76
+ enumerable: false
77
+ });
78
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
79
+ Object.defineProperty(inst, "toString", {
80
+ value: () => inst.message,
81
+ enumerable: false
82
+ });
83
+ };
84
+ var $ZodError = $constructor("$ZodError", initializer);
85
+ function flattenError(error, mapper = (issue2) => issue2.message) {
86
+ const fieldErrors = {};
87
+ const formErrors = [];
88
+ for (const sub of error.issues) {
89
+ if (sub.path.length > 0) {
90
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
91
+ fieldErrors[sub.path[0]].push(mapper(sub));
137
92
  } else {
138
- this.__proto__ = actualProto;
93
+ formErrors.push(mapper(sub));
139
94
  }
140
- this.name = "ZodError";
141
- this.issues = issues;
142
95
  }
143
- format(_mapper) {
144
- const mapper = _mapper || function(issue) {
145
- return issue.message;
146
- };
147
- const fieldErrors = { _errors: [] };
148
- const processError = (error) => {
149
- for (const issue of error.issues) {
150
- if (issue.code === "invalid_union") {
151
- issue.unionErrors.map(processError);
152
- } else if (issue.code === "invalid_return_type") {
153
- processError(issue.returnTypeError);
154
- } else if (issue.code === "invalid_arguments") {
155
- processError(issue.argumentsError);
156
- } else if (issue.path.length === 0) {
157
- fieldErrors._errors.push(mapper(issue));
158
- } else {
159
- let curr = fieldErrors;
160
- let i = 0;
161
- while (i < issue.path.length) {
162
- const el = issue.path[i];
163
- const terminal = i === issue.path.length - 1;
164
- if (!terminal) {
165
- curr[el] = curr[el] || { _errors: [] };
166
- } else {
167
- curr[el] = curr[el] || { _errors: [] };
168
- curr[el]._errors.push(mapper(issue));
169
- }
170
- curr = curr[el];
171
- i++;
96
+ return { formErrors, fieldErrors };
97
+ }
98
+ function formatError(error, mapper = (issue2) => issue2.message) {
99
+ const fieldErrors = { _errors: [] };
100
+ const processError = (error2) => {
101
+ for (const issue2 of error2.issues) {
102
+ if (issue2.code === "invalid_union" && issue2.errors.length) {
103
+ issue2.errors.map((issues) => processError({ issues }));
104
+ } else if (issue2.code === "invalid_key") {
105
+ processError({ issues: issue2.issues });
106
+ } else if (issue2.code === "invalid_element") {
107
+ processError({ issues: issue2.issues });
108
+ } else if (issue2.path.length === 0) {
109
+ fieldErrors._errors.push(mapper(issue2));
110
+ } else {
111
+ let curr = fieldErrors;
112
+ let i = 0;
113
+ while (i < issue2.path.length) {
114
+ const el = issue2.path[i];
115
+ const terminal = i === issue2.path.length - 1;
116
+ if (!terminal) {
117
+ curr[el] = curr[el] || { _errors: [] };
118
+ } else {
119
+ curr[el] = curr[el] || { _errors: [] };
120
+ curr[el]._errors.push(mapper(issue2));
172
121
  }
122
+ curr = curr[el];
123
+ i++;
173
124
  }
174
125
  }
175
- };
176
- processError(this);
177
- return fieldErrors;
178
- }
179
- static assert(value) {
180
- if (!(value instanceof _ZodError)) {
181
- throw new Error(`Not a ZodError: ${value}`);
182
126
  }
127
+ };
128
+ processError(error);
129
+ return fieldErrors;
130
+ }
131
+
132
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
133
+ var _a;
134
+ var $ZodRegistry = class {
135
+ constructor() {
136
+ this._map = /* @__PURE__ */ new WeakMap();
137
+ this._idmap = /* @__PURE__ */ new Map();
183
138
  }
184
- toString() {
185
- return this.message;
139
+ add(schema, ..._meta) {
140
+ const meta = _meta[0];
141
+ this._map.set(schema, meta);
142
+ if (meta && typeof meta === "object" && "id" in meta) {
143
+ this._idmap.set(meta.id, schema);
144
+ }
145
+ return this;
186
146
  }
187
- get message() {
188
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
147
+ clear() {
148
+ this._map = /* @__PURE__ */ new WeakMap();
149
+ this._idmap = /* @__PURE__ */ new Map();
150
+ return this;
189
151
  }
190
- get isEmpty() {
191
- return this.issues.length === 0;
152
+ remove(schema) {
153
+ const meta = this._map.get(schema);
154
+ if (meta && typeof meta === "object" && "id" in meta) {
155
+ this._idmap.delete(meta.id);
156
+ }
157
+ this._map.delete(schema);
158
+ return this;
192
159
  }
193
- flatten(mapper = (issue) => issue.message) {
194
- const fieldErrors = {};
195
- const formErrors = [];
196
- for (const sub of this.issues) {
197
- if (sub.path.length > 0) {
198
- const firstEl = sub.path[0];
199
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
200
- fieldErrors[firstEl].push(mapper(sub));
201
- } else {
202
- formErrors.push(mapper(sub));
203
- }
160
+ get(schema) {
161
+ const p = schema._zod.parent;
162
+ if (p) {
163
+ const pm = { ...this.get(p) ?? {} };
164
+ delete pm.id;
165
+ const f = { ...pm, ...this._map.get(schema) };
166
+ return Object.keys(f).length ? f : void 0;
204
167
  }
205
- return { formErrors, fieldErrors };
168
+ return this._map.get(schema);
206
169
  }
207
- get formErrors() {
208
- return this.flatten();
170
+ has(schema) {
171
+ return this._map.has(schema);
209
172
  }
210
173
  };
211
- ZodError.create = (issues) => {
212
- const error = new ZodError(issues);
213
- return error;
174
+ function registry() {
175
+ return new $ZodRegistry();
176
+ }
177
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
178
+
179
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
180
+ var initializer2 = (inst, issues) => {
181
+ $ZodError.init(inst, issues);
182
+ inst.name = "ZodError";
183
+ Object.defineProperties(inst, {
184
+ format: {
185
+ value: (mapper) => formatError(inst, mapper)
186
+ // enumerable: false,
187
+ },
188
+ flatten: {
189
+ value: (mapper) => flattenError(inst, mapper)
190
+ // enumerable: false,
191
+ },
192
+ addIssue: {
193
+ value: (issue2) => {
194
+ inst.issues.push(issue2);
195
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
196
+ }
197
+ // enumerable: false,
198
+ },
199
+ addIssues: {
200
+ value: (issues2) => {
201
+ inst.issues.push(...issues2);
202
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
203
+ }
204
+ // enumerable: false,
205
+ },
206
+ isEmpty: {
207
+ get() {
208
+ return inst.issues.length === 0;
209
+ }
210
+ // enumerable: false,
211
+ }
212
+ });
214
213
  };
214
+ var ZodError = $constructor("ZodError", initializer2);
215
215
 
216
216
  // src/index.ts
217
217
  var _hasPermissionPromise;
@@ -535,48 +535,51 @@ var MastraServer = class extends serverAdapter.MastraServer {
535
535
  if (params.queryParams) {
536
536
  try {
537
537
  params.queryParams = await this.parseQueryParams(route, params.queryParams);
538
- } catch (error$1) {
538
+ } catch (error) {
539
539
  this.mastra.getLogger()?.error("Error parsing query params", {
540
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
540
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
541
541
  });
542
- if (error$1 instanceof ZodError) {
543
- return reply.status(400).send(error.formatZodError(error$1, "query parameters"));
542
+ if (error instanceof ZodError) {
543
+ const { status, body } = this.resolveValidationError(route, error, "query");
544
+ return reply.status(status).send(body);
544
545
  }
545
546
  return reply.status(400).send({
546
547
  error: "Invalid query parameters",
547
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
548
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
548
549
  });
549
550
  }
550
551
  }
551
552
  if (params.body) {
552
553
  try {
553
554
  params.body = await this.parseBody(route, params.body);
554
- } catch (error$1) {
555
+ } catch (error) {
555
556
  this.mastra.getLogger()?.error("Error parsing body", {
556
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
557
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
557
558
  });
558
- if (error$1 instanceof ZodError) {
559
- return reply.status(400).send(error.formatZodError(error$1, "request body"));
559
+ if (error instanceof ZodError) {
560
+ const { status, body } = this.resolveValidationError(route, error, "body");
561
+ return reply.status(status).send(body);
560
562
  }
561
563
  return reply.status(400).send({
562
564
  error: "Invalid request body",
563
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
565
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
564
566
  });
565
567
  }
566
568
  }
567
569
  if (params.urlParams) {
568
570
  try {
569
571
  params.urlParams = await this.parsePathParams(route, params.urlParams);
570
- } catch (error$1) {
572
+ } catch (error) {
571
573
  this.mastra.getLogger()?.error("Error parsing path params", {
572
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
574
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
573
575
  });
574
- if (error$1 instanceof ZodError) {
575
- return reply.status(400).send(error.formatZodError(error$1, "path parameters"));
576
+ if (error instanceof ZodError) {
577
+ const { status, body } = this.resolveValidationError(route, error, "path");
578
+ return reply.status(status).send(body);
576
579
  }
577
580
  return reply.status(400).send({
578
581
  error: "Invalid path parameters",
579
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
582
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
580
583
  });
581
584
  }
582
585
  }
@@ -627,7 +630,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
627
630
  };
628
631
  const shouldApplyBodyLimit = this.bodyLimitOptions && ["POST", "PUT", "PATCH"].includes(route.method.toUpperCase());
629
632
  const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;
630
- const config = shouldApplyBodyLimit && maxSize ? { bodyLimit: maxSize } : void 0;
633
+ const config2 = shouldApplyBodyLimit && maxSize ? { bodyLimit: maxSize } : void 0;
631
634
  if (route.method.toUpperCase() === "ALL") {
632
635
  const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
633
636
  for (const method of methods) {
@@ -636,7 +639,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
636
639
  method,
637
640
  url: fastifyPath,
638
641
  handler,
639
- config
642
+ config: config2
640
643
  });
641
644
  } catch (err) {
642
645
  if (err instanceof Error && err.message.includes("already declared")) {
@@ -650,7 +653,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
650
653
  method: route.method,
651
654
  url: fastifyPath,
652
655
  handler,
653
- config
656
+ config: config2
654
657
  });
655
658
  }
656
659
  }
@@ -762,14 +765,14 @@ var MastraServer = class extends serverAdapter.MastraServer {
762
765
  const method = request.method;
763
766
  const path = urlPath;
764
767
  reply.raw.once("finish", () => {
765
- const duration = Date.now() - start;
768
+ const duration2 = Date.now() - start;
766
769
  const status = reply.statusCode;
767
770
  const level = this.httpLoggingConfig?.level || "info";
768
771
  const logData = {
769
772
  method,
770
773
  path,
771
774
  status,
772
- duration: `${duration}ms`
775
+ duration: `${duration2}ms`
773
776
  };
774
777
  if (this.httpLoggingConfig?.includeQueryParams) {
775
778
  logData.query = request.query;
@@ -785,7 +788,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
785
788
  });
786
789
  logData.headers = headers;
787
790
  }
788
- this.logger[level](`${method} ${path} ${status} ${duration}ms`, logData);
791
+ this.logger[level](`${method} ${path} ${status} ${duration2}ms`, logData);
789
792
  });
790
793
  });
791
794
  }