Skip to content

Commit

Permalink
fix: apply auto predicate registration env
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Jul 6, 2023
1 parent 497a8ac commit a80ab3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/chainhook/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ export async function buildChainhookServer(args: { db: PgStore }) {
}).withTypeProvider<TypeBoxTypeProvider>();

fastify.decorate('db', args.db);
fastify.addHook('onReady', waitForChainhookNode);
fastify.addHook('onReady', registerChainhookPredicates);
fastify.addHook('onClose', removeChainhookPredicates);
if (ENV.CHAINHOOK_AUTO_PREDICATE_REGISTRATION) {
fastify.addHook('onReady', waitForChainhookNode);
fastify.addHook('onReady', registerChainhookPredicates);
fastify.addHook('onClose', removeChainhookPredicates);
}
await fastify.register(Chainhook);

return fastify;
Expand Down
5 changes: 5 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const schema = Type.Object({
* coming from the valid instance
*/
CHAINHOOK_NODE_AUTH_TOKEN: Type.String(),
/**
* Register chainhook predicates automatically when the API is first launched. Set this to `false`
* if you're configuring your predicates manually for any reason.
*/
CHAINHOOK_AUTO_PREDICATE_REGISTRATION: Type.Boolean({ default: true }),

PGHOST: Type.String(),
PGPORT: Type.Number({ default: 5432, minimum: 0, maximum: 65535 }),
Expand Down

0 comments on commit a80ab3a

Please sign in to comment.