Skip to content

Commit 02146dd

Browse files
authored
Make fastify body limit configurable (#56)
1 parent 42482a4 commit 02146dd

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export function getServeCommand<Configuration, State>(
5454
new Option("--service-token-secret <secret>").env("HASURA_SERVICE_TOKEN_SECRET")
5555
)
5656
.addOption(new Option("--log-level <level>").env("HASURA_LOG_LEVEL").default("info"))
57-
.addOption(new Option("--pretty-print-logs").env("HASURA_PRETTY_PRINT_LOGS").default(false));
57+
.addOption(new Option("--pretty-print-logs").env("HASURA_PRETTY_PRINT_LOGS").default(false))
58+
.addOption(
59+
new Option("--body-limit <bytes>").env("HASURA_BODY_LIMIT").default(31457280).argParser(parseIntOption)
60+
);
5861

5962
if (connector) {
6063
command.action(async (options: ServerOptions) => {

src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface ServerOptions {
7979
serviceTokenSecret: string | undefined;
8080
logLevel: string;
8181
prettyPrintLogs: string;
82+
bodyLimit: number | undefined;
8283
}
8384

8485
const tracer = opentelemetry.trace.getTracer("ndc-sdk-typescript.server");
@@ -134,7 +135,7 @@ export async function startServer<Configuration, State>(
134135

135136
const server = Fastify({
136137
logger: configureFastifyLogging(options),
137-
bodyLimit: 1048576 * 30, // 30mb body limit
138+
bodyLimit: options.bodyLimit ?? 1048576 * 30, // 30mb body limit
138139
ajv: {
139140
customOptions: customAjvOptions,
140141
},

0 commit comments

Comments
 (0)