diff --git a/.talismanrc b/.talismanrc index 9ec4f3fb9..7803cb249 100644 --- a/.talismanrc +++ b/.talismanrc @@ -11,6 +11,8 @@ fileignoreconfig: checksum: 25a58ba4ecfb8606daf5efbae6a1f0f2efe4e87a4a8a18e745712b39198d93a5 - filename: packages/api-sdk/src/test/campaign-api.test.ts checksum: b200d9e1fec310660a91e99cd048b24cbe983e0f9f965861d061a7f0992af43e +- filename: packages/healthcheck/src/checks/brevo.ts + checksum: a1fbeb01d83167b791eb8175eeb80178cc6da19bb83a6ba3cb2077ca96ebda5e - filename: packages/utils/src/object.ts checksum: 9893602dd7197e44a7c361e44c31b5fb86a025227af95c02998a6857bd1a694b - filename: server/.env.example diff --git a/packages/healthcheck/src/checks/brevo.ts b/packages/healthcheck/src/checks/brevo.ts new file mode 100644 index 000000000..8e5044c04 --- /dev/null +++ b/packages/healthcheck/src/checks/brevo.ts @@ -0,0 +1,23 @@ +import { Check } from './check'; + +export function brevoCheck(apiKey: string): Check { + return { + name: 'brevo', + async test() { + const url = + 'https://api.brevo.com/v3/smtp/statistics/aggregatedReport'; + const options = { + method: 'GET', + headers: { + accept: 'application/json', + 'api-key': apiKey + } + }; + await fetch(url, options).then(res => { + if(res.status !== 200) { + throw new Error('Brevo API is not available'); + } + }); + } + }; +} diff --git a/packages/healthcheck/src/index.ts b/packages/healthcheck/src/index.ts index ea7ccb5f0..425ba91bf 100644 --- a/packages/healthcheck/src/index.ts +++ b/packages/healthcheck/src/index.ts @@ -1,3 +1,4 @@ +export * from './checks/brevo'; export * from './checks/postgres'; export * from './checks/redis'; export * from './checks/s3'; diff --git a/server/src/infra/server.ts b/server/src/infra/server.ts index 6a0c7e80e..e8cd1311d 100644 --- a/server/src/infra/server.ts +++ b/server/src/infra/server.ts @@ -7,6 +7,7 @@ import util from 'node:util'; import { healthcheck, + brevoCheck, postgresCheck, redisCheck, s3Check @@ -121,6 +122,7 @@ export function createServer(): Server { '/', healthcheck({ checks: [ + brevoCheck(config.mailer.apiKey ?? ''), redisCheck(config.redis.url), postgresCheck(config.db.url), s3Check(config.s3)