├── .gitignore ├── package.json ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pfcheck", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "check": "node index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "MIT", 12 | "dependencies": { 13 | "cross-fetch": "^3.1.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pfcheck 2 | 3 | Quickly check for Pfizer vaccine availability at the Manitoba vaccine super-sites. 4 | 5 | 6 | ### Install 7 | 8 | ```sh 9 | npm install 10 | ``` 11 | 12 | ### Usage 13 | 14 | ```sh 15 | npm run check 16 | ``` 17 | 18 | If there is availability at any of the locations not listed in `IGNORE_LOCATIONS` (by default Thompson and Dauphin), it will display them. If there is no availability, it will output nothing. 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | const fetch = require('cross-fetch'); 3 | 4 | const AVAILABILITY_URL = 'https://manitobavaxx.ca/apiV1/getAvailalibity'; 5 | const PFIZER_PREFIX = 'PF'; 6 | const NOT_AVAILABLE_TIME_STRING = 'N/A'; 7 | 8 | const IGNORE_LOCATIONS = ['Thompson','Dauphin']; 9 | 10 | const postData = async (url = '', data = {}) => { 11 | const response = await fetch(url, { 12 | method: 'POST', 13 | cache: 'no-cache', 14 | headers: { 15 | 'Accept': 'application/json' 16 | }, 17 | referrerPolicy: 'no-referrer', 18 | }); 19 | return response.json(); 20 | }; 21 | 22 | const parseData = (data = {}) => { 23 | const locations = []; 24 | for (const [key, value] of Object.entries(data.sites)) { 25 | if (!key.startsWith(PFIZER_PREFIX)) { 26 | continue; 27 | } 28 | if (value.startTime===NOT_AVAILABLE_TIME_STRING) { 29 | continue; 30 | } 31 | const location = key.substr(2); 32 | const date = new Date(value.startTime).toLocaleString('en-CA', {tiemZone: 'America/Winnipeg'}); 33 | 34 | locations.push({location,date}); 35 | } 36 | 37 | return locations; 38 | } 39 | 40 | const filterLocations = (data) => { 41 | return data.filter(e => { 42 | return IGNORE_LOCATIONS.indexOf(e.location) === -1; 43 | }); 44 | }; 45 | 46 | const showOutput = (data) => { 47 | if (data.length!==0) { 48 | console.log(data); 49 | } 50 | }; 51 | 52 | 53 | postData(AVAILABILITY_URL) 54 | .then(parseData) 55 | .then(filterLocations) 56 | .then(showOutput); 57 | --------------------------------------------------------------------------------