Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add monitoring for Brevo service in healthcheck endpoint #991

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions packages/healthcheck/src/checks/brevo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Check } from './check';

export function brevoCheck(apiKey: string): Check {
return {
name: 'brevo',
async test() {
const url =
'https://api.breveo.com/v3/smtp/statistics/aggregatedReport';
loicguillois marked this conversation as resolved.
Show resolved Hide resolved
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');
}
});
}
};
}
1 change: 1 addition & 0 deletions packages/healthcheck/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './checks/brevo';
export * from './checks/postgres';
export * from './checks/redis';
export * from './checks/s3';
Expand Down
2 changes: 2 additions & 0 deletions server/src/infra/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import util from 'node:util';

import {
healthcheck,
brevoCheck,
postgresCheck,
redisCheck,
s3Check
Expand Down Expand Up @@ -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)
Expand Down
Loading