-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
31 lines (24 loc) · 920 Bytes
/
main.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
require('dotenv').config();
const { CronJob } = require("cron");
const express = require("express");
const app = express();
const generateRandomColorContrast = require('./generateRandomColorContrast');
// trigger every:
// 00:15, 04:15, 12:15, 16:15
const job = new CronJob("15 0,4,12,16 * * *", () => {
console.log("Triggered cron job");
console.log('Generating random color contrast...');
const imageFilePath = `${__dirname}/public/output.png`;
generateRandomColorContrast({ imageFilePath }).then(() => {
console.log('Generated random color contrast and sent to Mastodon!');
})
}, null, false, 'Europe/London');
job.start();
// glitch requires a server...
app.use(express.static("public"));
app.get("/", (_request, response) => {
response.sendStatus(200);
});
const listener = app.listen(process.env.PORT, () => {
console.log(`Your app is listening on port ${listener.address().port}`);
});