-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (29 loc) · 1019 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require('dotenv').config();
const { main } = require('./app.js');
const { pruneDatabaseAndEmail } = require('./database/database.js');
exports.mainJob = async (req, res) => {
console.log("Running scheduled half-hourly event check");
try {
await main();
console.log("Main function executed successfully");
res.status(200).send('Job 1 executed successfully');
} catch (error) {
console.error("Error running main:", error);
res.status(500).send('Internal Server Error');
}
};
exports.pruneDatabaseAndEmailJob = async (req, res) => {
console.log("Running scheduled weekly prune");
try {
await pruneDatabaseAndEmail();
console.log("Pruning complete");
res.status(200).send('Job 2 executed successfully');
} catch (error) {
console.error("Error running prune:", error);
res.status(500).send('Internal Server Error');
}
};
exports.mainJob = (req, res) => {
console.log("Cloud Function executed");
res.status(200).send("Cloud Function executed successfully");
};