Files
onearmy-community-platform/functions/src/scheduled/tasks.ts
2023-10-09 17:59:54 +02:00

20 lines
850 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/************ Scheduled tasks ***********************************************************
Scripts executed on a cron schedule, such as daily or weekly
https://firebase.google.com/docs/functions/schedule-functions
************************************************************************************/
import * as functions from 'firebase-functions'
import { BackupDatabase } from '../Firebase/firestoreDBExport'
import * as FirebaseSync from '../Firebase/firebaseSync'
/** Trigger tasks daily at 2am https://crontab.guru/#0_2_*_*_* */
export const dailyTasks = functions
.runWith({ memory: '512MB' })
.pubsub.schedule('0 2 * * *')
.onRun(async (context) => {
functions.logger.log('[dailyTasks] Start', context)
const backupStatus = await BackupDatabase()
functions.logger.log(backupStatus)
await FirebaseSync.syncAll()
})