Skip to content

Commit 45b0426

Browse files
authored
chore: fix fastify deprecation warning about querystringParser (#8876)
1 parent b87b37f commit 45b0426

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

packages/api/test/utils/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {ApplicationMethods, addSszContentTypeParser} from "../../src/utils/serve
88
export function getTestServer(): {server: FastifyInstance; start: () => Promise<string>} {
99
const server = fastify({
1010
ajv: {customOptions: {coerceTypes: "array"}},
11-
querystringParser: (str) => parseQueryString(str, {comma: true, parseArrays: false}),
11+
routerOptions: {
12+
querystringParser: (str) => parseQueryString(str, {comma: true, parseArrays: false}),
13+
},
1214
});
1315

1416
addSszContentTypeParser(server);

packages/beacon-node/src/api/rest/base.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ export class RestApiServer {
7373
const server = fastify({
7474
logger: false,
7575
ajv: {customOptions: {coerceTypes: "array"}},
76-
querystringParser: (str) =>
77-
parseQueryString(str, {
78-
// Array as comma-separated values must be supported to be OpenAPI spec compliant
79-
comma: true,
80-
// Drop support for array query strings like `id[0]=1&id[1]=2&id[2]=3` as those are not required to
81-
// be OpenAPI spec compliant and results are inconsistent, see https://github.com/ljharb/qs/issues/331.
82-
// The schema validation will catch this and throw an error as parsed query string results in an object.
83-
parseArrays: false,
84-
}),
76+
routerOptions: {
77+
querystringParser: (str) =>
78+
parseQueryString(str, {
79+
// Array as comma-separated values must be supported to be OpenAPI spec compliant
80+
comma: true,
81+
// Drop support for array query strings like `id[0]=1&id[1]=2&id[2]=3` as those are not required to
82+
// be OpenAPI spec compliant and results are inconsistent, see https://github.com/ljharb/qs/issues/331.
83+
// The schema validation will catch this and throw an error as parsed query string results in an object.
84+
parseArrays: false,
85+
}),
86+
},
8587
bodyLimit: opts.bodyLimit,
8688
http: {maxHeaderSize: opts.headerLimit},
8789
});

packages/light-client/test/utils/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export async function startServer(
2121
const server = fastify({
2222
logger: false,
2323
ajv: {customOptions: {coerceTypes: "array"}},
24-
querystringParser: (str) => parseQueryString(str, {comma: true, parseArrays: false}),
24+
routerOptions: {
25+
querystringParser: (str) => parseQueryString(str, {comma: true, parseArrays: false}),
26+
},
2527
});
2628

2729
addSszContentTypeParser(server);

0 commit comments

Comments
 (0)