Last active
March 11, 2021 10:31
-
-
Save sincraianul/35dbeef6036c5dd8217e880adccbd8fb to your computer and use it in GitHub Desktop.
rovaxxer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios') | |
const chalk = require('chalk') | |
const Job = require('cron').CronJob; | |
const SESSION_ID = 'xxx' // replace me, get it from cookies | |
const getCentres = () => { | |
/** | |
* replace with your own payload that's sent to https://programare.vaccinare-covid.gov.ro/scheduling/api/centres when you press 'Filtreaza' | |
* | |
* should look like: | |
* { | |
* "countyID": 12, | |
* "localityID": null, | |
* "name": null, | |
* "identificationCode": "XXX", | |
* "masterPersonnelCategoryID": -4, | |
* "personnelCategoryID": 32, | |
* "recipientID": 0 | |
* } | |
*/ | |
const payload = { | |
"countyID": 12, | |
"localityID": null, | |
"name": null, | |
"identificationCode": "XXX", // replace me | |
"masterPersonnelCategoryID": -4, // replace me | |
"personnelCategoryID": 32, // replace me | |
"recipientID": 0 // replace me | |
}; | |
return axios.post( | |
'https://programare.vaccinare-covid.gov.ro/scheduling/api/centres?page=0&size=20&sort=,', | |
payload, | |
{ | |
headers: { | |
Cookie: `SESSION=${SESSION_ID}` // replace with your own | |
} | |
} | |
) | |
.then(({ data: { content } }) => { | |
content && content.forEach(({ name, availableSlots, boosterDays }) => { | |
if (availableSlots) { | |
switch(boosterDays) { | |
case 21: | |
console.log(chalk.green(`🚀 centre "${name}" - Pfizer - has ${availableSlots} slots`)); | |
case 28: | |
console.log(chalk.green(`🚀 centre "${name}" - Moderna - has ${availableSlots} slots`)); | |
case 56: | |
console.log(chalk.green(`🚀 centre "${name}" - Astra Zeneca - has ${availableSlots} slots`)); | |
default: | |
console.log(chalk.green(`🚀 centre "${name}" has ${availableSlots} slots`)); | |
} | |
} | |
}); | |
}) | |
.catch((e) => { | |
console.log(chalk.red('error occurred when getting centres'), e) | |
}) | |
} | |
const job = new Job('*/10 * * * * *', async () => { | |
console.log(chalk.yellow('Checking centres...')) | |
await getCentres() | |
}); | |
job.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "rovaxxer", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"scripts": { | |
"start": "node index.js" | |
}, | |
"dependencies": { | |
"axios": "^0.21.1", | |
"chalk": "^4.1.0", | |
"cron": "^1.8.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment