Reduce controller logic scope

This commit is contained in:
Mike Conrad
2025-05-20 14:00:44 -04:00
parent 5df94eaafa
commit 3c44fcc062
4 changed files with 114 additions and 108 deletions

19
app/Helpers/Webhook.ts Normal file
View File

@ -0,0 +1,19 @@
import env from '#start/env'
export async function sendDataToWebhook(responseData:{ version: number, updatedAt: Date, numberOfRecords: number, data: unknown}) {
try {
console.log('syncing to webhook')
await fetch(env.get('WEBHOOK_URL'),
{
headers:
{
'content-type': 'application/json'
},
method: 'POST',
body: JSON.stringify(responseData)
}
)
} catch (e) {
console.error('error sending webhook data', e)
}
}