Schedule invoices cron, add polling logs

This commit is contained in:
austinkelsay 2024-11-08 11:01:25 -06:00
parent 6978fb06dd
commit 473595cf90
No known key found for this signature in database
GPG Key ID: 44CB4EC6D9F2FA02
2 changed files with 7 additions and 2 deletions

View File

@ -79,13 +79,14 @@ export default async function handler(req, res) {
// Start polling for this zap request
let attempts = 0;
const pollInterval = setInterval(async () => {
console.log('Polling for invoice', attempts);
try {
console.log('Polling for invoice', attempts);
const pollResponse = await axios.get(`${BACKEND_URL}/api/invoices/polling`, {
headers: {
'Authorization': PLEBDEVS_API_KEY
}
});
console.log('Polling response', pollResponse.data);
// If no pending invoices or we've reached max attempts, stop polling
if (pollResponse.data.pending === 0 || attempts >= 120) {

View File

@ -4,10 +4,14 @@
{
"path": "/api/users/subscription/cron",
"schedule": "0 0 * * *"
},
{
"path": "/api/invoices/polling",
"schedule": "*/10 * * * *"
}
],
"functions": {
"src/pages/api/lightning-address/lnd.js": {
"src/pages/api/invoices/polling.js": {
"maxDuration": 120
}
}