Skip to content

Commit

Permalink
fix(agent): add body parser options to allow increase body limits (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-moncel committed Oct 16, 2023
1 parent baaba5c commit a4de720
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default class Agent<S extends TSchema = TSchema> extends FrameworkMounter
// Build router
const router = new Router();
router.all('(.*)', cors({ credentials: true, maxAge: 24 * 3600, privateNetworkAccess: true }));
router.use(bodyParser({ jsonLimit: '50mb' }));
router.use(bodyParser({ jsonLimit: this.options.maxBodySize }));
routes.forEach(route => route.setupRoutes(router));

return router;
Expand Down
1 change: 1 addition & 0 deletions packages/agent/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type AgentOptions = {
webhookCustomActions?: boolean;
updateRecordCustomActions?: boolean;
};
maxBodySize?: string;
};
export type AgentOptionsWithDefaults = Readonly<Required<AgentOptions>>;

Expand Down
1 change: 1 addition & 0 deletions packages/agent/src/utils/options-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class OptionsValidator {
copyOptions.loggerLevel = copyOptions.loggerLevel || 'Info';
copyOptions.skipSchemaUpdate = copyOptions.skipSchemaUpdate || false;
copyOptions.instantCacheRefresh = copyOptions.instantCacheRefresh ?? true;
copyOptions.maxBodySize = copyOptions.maxBodySize || '50mb';

if (copyOptions.instantCacheRefresh && copyOptions.permissionsCacheDurationInSeconds) {
copyOptions.logger(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export default Factory.define<AgentOptionsWithDefaults>(() => ({
typingsMaxDepth: 5,
typingsPath: null,
experimental: {},
maxBodySize: '50mb',
}));

0 comments on commit a4de720

Please sign in to comment.