-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
36 lines (25 loc) · 1021 Bytes
/
index.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
const cron = require("node-cron");
const { checkSlots } = require("./notifier");
/* ----------------------- CONFIGURATIONS ------------------------ */
// Basic Filters
const AGE = 18;
const DATE = "19-05-2021";
const DOSE = 1;
// Other Options
const type = process.env.TYPE || "pincode"; // Find slots by "pincode" or "dist"
const PINCODES = ["360004"];
const DISTRICT_IDS = [775]; //Rajkot Corp
const SCHEDULE = "*/3 * * * * *"; // Every 3 second
SOUND_ALERT = true;
/* --------------------------------CRON JOB--------------------------------- */
const filters = { age: AGE, date: DATE, dose: DOSE };
const job = cron.schedule(SCHEDULE, function () {
const values = type === "dist" ? DISTRICT_IDS : PINCODES;
console.log("\n"); // just to divide each cron logs
const promises = values.map(async (value) => {
await checkSlots(type, value, { value, ...filters });
});
return Promise.all(promises);
});
console.log(`Looking for an available slot on ${DATE}\nScheduled: ${SCHEDULE}`);
job.start();