@@ -25,11 +25,11 @@ const ServerOptionsSchema = Type.Object({
25
25
external_base_url : Type . String ( ) ,
26
26
27
27
/** Wait for the chainhook node to be available before submitting predicates */
28
- wait_for_chainhook_node : Type . Boolean ( { default : true } ) ,
28
+ wait_for_chainhook_node : Type . Optional ( Type . Boolean ( { default : true } ) ) ,
29
29
/** Validate the JSON schema of received chainhook payloads and report errors when invalid */
30
- validate_chainhook_payloads : Type . Boolean ( { default : false } ) ,
30
+ validate_chainhook_payloads : Type . Optional ( Type . Boolean ( { default : false } ) ) ,
31
31
/** Size limit for received chainhook payloads (default 40MB) */
32
- body_limit : Type . Number ( { default : 41943040 } ) ,
32
+ body_limit : Type . Optional ( Type . Number ( { default : 41943040 } ) ) ,
33
33
} ) ;
34
34
/** Local event server connection and authentication options */
35
35
export type ServerOptions = Static < typeof ServerOptionsSchema > ;
@@ -194,7 +194,10 @@ export async function buildServer(
194
194
} ,
195
195
} ,
196
196
async ( request , reply ) => {
197
- if ( serverOpts . validate_chainhook_payloads && ! compiledSchema . Check ( request . body ) ) {
197
+ if (
198
+ ( serverOpts . validate_chainhook_payloads ?? false ) &&
199
+ ! compiledSchema . Check ( request . body )
200
+ ) {
198
201
logger . error (
199
202
[ ...compiledSchema . Errors ( request . body ) ] ,
200
203
`ChainhookEventObserver received an invalid payload`
@@ -218,10 +221,10 @@ export async function buildServer(
218
221
trustProxy : true ,
219
222
logger : PINO_CONFIG ,
220
223
pluginTimeout : 0 , // Disable so ping can retry indefinitely
221
- bodyLimit : serverOpts . body_limit ,
224
+ bodyLimit : serverOpts . body_limit ?? 41943040 , // 40MB
222
225
} ) . withTypeProvider < TypeBoxTypeProvider > ( ) ;
223
226
224
- if ( serverOpts . wait_for_chainhook_node ) {
227
+ if ( serverOpts . wait_for_chainhook_node ?? true ) {
225
228
fastify . addHook ( 'onReady' , waitForNode ) ;
226
229
}
227
230
fastify . addHook ( 'onReady' , registerPredicates ) ;
0 commit comments