Skip to content

Commit

Permalink
#296: added body limit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
petermasking committed Sep 26, 2024
1 parent 32d9605 commit b00842b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/cli/src/commands/StartServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ export default class StartServer implements Command
const runtimeConfigFile = args.getOptionalArgument('--config', undefined);
const serviceConfigFile = args.getRequiredArgument('--service');

const bodyLimitString = args.getOptionalArgument('--http-body-limit', undefined);
const bodyLimit = bodyLimitString !== undefined ? Number.parseInt(bodyLimitString) : undefined;

const configurationManager = new ConfigurationManager();

await configurationManager.configureEnvironment(environmentFile);

const runtimeConfiguration = await configurationManager.getRuntimeConfiguration(runtimeConfigFile);
const serverConfiguration = await configurationManager.getServerConfiguration(serviceConfigFile);

const httpServer = await this.#buildServer(runtimeConfiguration, serverConfiguration);
const httpServer = await this.#buildServer(runtimeConfiguration, serverConfiguration, bodyLimit);

return this.#runServer(httpServer);
}

async #buildServer(runtimeConfiguration: RuntimeConfiguration, serverConfiguration: ServerConfiguration): Promise<HttpServer>
async #buildServer(runtimeConfiguration: RuntimeConfiguration, serverConfiguration: ServerConfiguration, bodyLimit?: number): Promise<HttpServer>
{
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [protocol, host, port] = serverConfiguration.url.split(':');
Expand All @@ -50,7 +53,7 @@ export default class StartServer implements Command

const server = await serverBuilder.build(serverConfiguration);

return new HttpServer(server, port);
return new HttpServer(server, port, bodyLimit);
}

#runServer(httpServer: HttpServer): Promise<void>
Expand Down

0 comments on commit b00842b

Please sign in to comment.