manifold/functions/src/keep-awake.ts

26 lines
634 B
TypeScript
Raw Normal View History

2021-12-18 02:12:58 +00:00
import * as functions from 'firebase-functions'
import { callCloudFunction } from './call-cloud-function'
export const keepAwake = functions.pubsub
.schedule('every 1 minutes')
.onRun(async () => {
await Promise.all([
callCloudFunction('placeBet'),
callCloudFunction('resolveMarket'),
2021-12-24 21:14:02 +00:00
callCloudFunction('sellBet'),
2021-12-18 02:12:58 +00:00
])
2021-12-18 20:29:27 +00:00
await sleep(30)
await Promise.all([
callCloudFunction('placeBet'),
callCloudFunction('resolveMarket'),
2021-12-24 21:14:02 +00:00
callCloudFunction('sellBet'),
2021-12-18 20:29:27 +00:00
])
2021-12-18 02:12:58 +00:00
})
2021-12-18 20:29:27 +00:00
const sleep = (seconds: number) => {
return new Promise((resolve) => setTimeout(resolve, seconds * 1000))
}