-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (23 loc) · 768 Bytes
/
Copy pathindex.js
File metadata and controls
28 lines (23 loc) · 768 Bytes
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
const express = require("express");
const app = express();
const { createPost } = require("./functions/createPost");
const cron = require("node-cron");
const { deployToRender } = require("./functions/deployToRender");
require("dotenv").config();
const port = process.env.PORT || 4000;
// Try to post every 4 hours
cron.schedule("0 */4 * * *", async () => {
createPost();
});
app.get("/", (req, res) => {
res.send("Breaking Casting News is up and running!");
});
app.listen(port, () => {
console.log(`Listening on port ${port}...`);
});
if (process.env.NODE_ENV === "production") {
// Redeploy render service at: 3:15 AM, 7:15 AM, 11:15 AM, 3:15 PM, 7:15 PM, and 11:15 PM
cron.schedule("15 3,7,11,15,19,23 * * *", () => {
deployToRender();
});
}