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-02-25 17:34:09 +00:00
|
|
|
const { auction } = require('./auction')
|
2022-07-07 19:14:22 +00:00
|
|
|
const { earn } = require('./earn')
|
2022-01-25 19:34:51 +00:00
|
|
|
const { ApolloClient, HttpLink, InMemoryCache } = require('@apollo/client')
|
|
|
|
const { indexItem, indexAllItems } = require('./search')
|
|
|
|
const fetch = require('cross-fetch')
|
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()
|
2022-01-25 19:34:51 +00:00
|
|
|
const apollo = new ApolloClient({
|
|
|
|
link: new HttpLink({
|
|
|
|
uri: `${process.env.SELF_URL}/api/graphql`,
|
|
|
|
fetch
|
|
|
|
}),
|
|
|
|
cache: new InMemoryCache(),
|
|
|
|
defaultOptions: {
|
|
|
|
watchQuery: {
|
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
nextFetchPolicy: 'network-only'
|
|
|
|
},
|
|
|
|
query: {
|
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
nextFetchPolicy: 'network-only'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const args = { boss, models, apollo }
|
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-25 19:34:51 +00:00
|
|
|
await boss.work('indexItem', indexItem(args))
|
|
|
|
await boss.work('indexAllItems', indexAllItems(args))
|
2022-02-25 17:34:09 +00:00
|
|
|
await boss.work('auction', auction(args))
|
2022-03-17 20:13:19 +00:00
|
|
|
await boss.work('earn', earn(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()
|