@@ -28,11 +28,15 @@ export type RequestWithExtraProps = Request & {
2828 * @property _process - Process object for environment variables (for testing
2929 * purposes)
3030 * @property apiKeyEnvVarName - Environment variable name for the API key
31+ * @property maxRequestBodySize - Controls the maximum request body size. If
32+ * this is a number, then the value specifies the number of bytes; if it is a
33+ * string, the value is passed to the bytes library for parsing.
3134 */
3235export type FunctionConfig = {
3336 _console ?: typeof console ;
3437 _process ?: typeof process ;
3538 apiKeyEnvVarName ?: string ;
39+ maxRequestBodySize ?: string | number ;
3640} ;
3741
3842/**
@@ -62,6 +66,7 @@ export const createExpressApp =
6266 _console = console ,
6367 _process = process ,
6468 apiKeyEnvVarName = 'LAMBDA_API_KEY' ,
69+ maxRequestBodySize = '1mb' ,
6570 } : FunctionConfig = { } ) =>
6671 ( handler : RequestHandler ) => {
6772 const app = express ( ) ;
@@ -75,6 +80,7 @@ export const createExpressApp =
7580
7681 // This is the options we pass to the `json()` middleware.
7782 const jsonOptions = {
83+ limit : maxRequestBodySize ,
7884 // This is a hack to retain the raw body on the request object. We need
7985 // this to verify the signature of the request.
8086 verify (
0 commit comments