-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (51 loc) · 1.11 KB
/
app.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const cron = require('cron');
const sendSms = require('./twilio');
require('dotenv').config();
const { getCovidStats } = require('./getCovid');
const { getQuote } = require('./getQuote');
const { getWeather } = require('./getWeather');
const { getMyTodos } = require('./getTodos');
// at 11 am everyday (weather)
weatherJob = new cron.CronJob(
'0 1 * * *',
async () => {
const weather = await getWeather();
sendSms(process.env.MY_NUMBER, weather);
},
null,
true,
'America/Los_Angeles'
);
// every 8 hours (Todos)
todosJob = new cron.CronJob(
'0 */8 * * *',
async () => {
const myTodos = await getMyTodos();
sendSms(process.env.MY_NUMBER, myTodos);
},
null,
true,
'America/Los_Angeles'
);
// at 12 pm everyday (covid)
covidJob = new cron.CronJob(
'0 2 * * *',
async () => {
const covidStats = await getCovidStats();
sendSms(process.env.MY_NUMBER, covidStats);
},
null,
true,
'America/Los_Angeles'
);
// at 5 pm everyday (Quote)
quoteJob = new cron.CronJob(
'0 7 * * *',
async () => {
const quote = await getQuote();
sendSms(process.env.MY_NUMBER, quote);
},
null,
true,
'America/Los_Angeles'
);