File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,19 @@ import * as Sentry from '@sentry/node'
3
3
import cors from '@fastify/cors'
4
4
import swagger from '@fastify/swagger'
5
5
import { fastify , FastifyInstance , FastifyServerOptions } from 'fastify'
6
- import { PG_META_REQ_HEADER } from './constants.js'
6
+ import { PG_META_REQ_HEADER , MAX_BODY_LIMIT } from './constants.js'
7
7
import routes from './routes/index.js'
8
8
import { extractRequestForLogging } from './utils.js'
9
9
// Pseudo package declared only for this module
10
10
import pkg from '#package.json' with { type : 'json' }
11
11
12
12
export const build = ( opts : FastifyServerOptions = { } ) : FastifyInstance => {
13
- const app = fastify ( { disableRequestLogging : true , requestIdHeader : PG_META_REQ_HEADER , ...opts } )
13
+ const app = fastify ( {
14
+ disableRequestLogging : true ,
15
+ requestIdHeader : PG_META_REQ_HEADER ,
16
+ bodyLimit : MAX_BODY_LIMIT ,
17
+ ...opts ,
18
+ } )
14
19
Sentry . setupFastifyErrorHandler ( app )
15
20
16
21
app . setErrorHandler ( ( error , request , reply ) => {
Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ export const PG_META_MAX_RESULT_SIZE = process.env.PG_META_MAX_RESULT_SIZE_MB
57
57
parseInt ( process . env . PG_META_MAX_RESULT_SIZE_MB , 10 ) * 1024 * 1024
58
58
: 2 * 1024 * 1024 * 1024 // default to 2GB max query size result
59
59
60
+ export const MAX_BODY_LIMIT = process . env . PG_META_MAX_BODY_LIMIT_MB
61
+ ? // Fastify server max body size allowed, is in bytes, convert from MB to Bytes
62
+ parseInt ( process . env . PG_META_MAX_BODY_LIMIT_MB , 10 ) * 1024 * 1024
63
+ : 3 * 1024 * 1024
64
+
60
65
export const DEFAULT_POOL_CONFIG : PoolConfig = {
61
66
max : 1 ,
62
67
connectionTimeoutMillis : PG_CONN_TIMEOUT_SECS * 1000 ,
You can’t perform that action at this time.
0 commit comments