mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-05-21 01:12:03 +00:00
Schedule invoices cron, add polling logs
This commit is contained in:
parent
6978fb06dd
commit
473595cf90
@ -79,13 +79,14 @@ export default async function handler(req, res) {
|
|||||||
// Start polling for this zap request
|
// Start polling for this zap request
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const pollInterval = setInterval(async () => {
|
const pollInterval = setInterval(async () => {
|
||||||
try {
|
|
||||||
console.log('Polling for invoice', attempts);
|
console.log('Polling for invoice', attempts);
|
||||||
|
try {
|
||||||
const pollResponse = await axios.get(`${BACKEND_URL}/api/invoices/polling`, {
|
const pollResponse = await axios.get(`${BACKEND_URL}/api/invoices/polling`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': PLEBDEVS_API_KEY
|
'Authorization': PLEBDEVS_API_KEY
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('Polling response', pollResponse.data);
|
||||||
|
|
||||||
// If no pending invoices or we've reached max attempts, stop polling
|
// If no pending invoices or we've reached max attempts, stop polling
|
||||||
if (pollResponse.data.pending === 0 || attempts >= 120) {
|
if (pollResponse.data.pending === 0 || attempts >= 120) {
|
||||||
|
@ -4,10 +4,14 @@
|
|||||||
{
|
{
|
||||||
"path": "/api/users/subscription/cron",
|
"path": "/api/users/subscription/cron",
|
||||||
"schedule": "0 0 * * *"
|
"schedule": "0 0 * * *"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/api/invoices/polling",
|
||||||
|
"schedule": "*/10 * * * *"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"functions": {
|
"functions": {
|
||||||
"src/pages/api/lightning-address/lnd.js": {
|
"src/pages/api/invoices/polling.js": {
|
||||||
"maxDuration": 120
|
"maxDuration": 120
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user