stacker.news/worker/index.js

26 lines
740 B
JavaScript
Raw Normal View History

2022-01-05 20:37:34 +00:00
const PgBoss = require('pg-boss')
const dotenv = require('dotenv')
dotenv.config({ path: '..' })
2022-01-17 17:41:17 +00:00
const { PrismaClient } = require('@prisma/client')
const { checkInvoice, checkWithdrawal } = require('./wallet')
const { repin } = require('./repin')
const { trust } = require('./trust')
2022-01-05 20:37:34 +00:00
async function work () {
2022-01-17 17:41:17 +00:00
const boss = new PgBoss(process.env.DATABASE_URL)
const models = new PrismaClient()
const args = { boss, models }
2022-01-14 17:28:05 +00:00
2022-01-17 17:41:17 +00:00
boss.on('error', error => console.error(error))
2022-01-07 16:32:31 +00:00
2022-01-17 17:41:17 +00:00
await boss.start()
await boss.work('checkInvoice', checkInvoice(args))
await boss.work('checkWithdrawal', checkWithdrawal(args))
await boss.work('repin-*', repin(args))
await boss.work('trust', trust(args))
2022-01-05 20:37:34 +00:00
2022-01-17 17:41:17 +00:00
console.log('working jobs')
2022-01-05 20:37:34 +00:00
}
work()