Socialify

Folder ..

Viewing index.js
61 lines (55 loc) • 1.8 KB

 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
57
58
59
60
61
const express = require("express");
const cors = require("cors")({
    origin: true,
});
const axios = require("axios");
const app = express();
const port = 4000;

app.use(cors);
app.options("*", cors);

app.get("/", (req, res) => {
    res.send("Son of Vaccinosaurus says Grrrrr!");
});

app.get("/api/pin", (req, res) => {
    const pincode = req.query.pincode;
    const date = req.query.date;
    const config = {
        method: "get",
        url: `https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=${pincode}&date=${date}`,
        headers: {
            accept: "application/json",
            "Accept-Language": "hi_IN",
            "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36"
        },
    };

    axios(config)
        .then(function (response) {
            res.send(response.data);
        })
        .catch(function (error) {
            res.send(error);
        });
});
app.get("/api/district", (req, res) => {
    const districtID = req.query.district_id;
    const date = req.query.date;
    const config = {
        method: "get",
        url: `https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=${districtID}&date=${date}`,
        headers: {
            accept: "application/json",
            "Accept-Language": "hi_IN",
            "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36"
        },
    };

    axios(config)
        .then(function (response) {
            res.send(response.data);
        })
        .catch(function (error) {
            res.send(error);
        });
});

app.listen(port, () => {
    console.log(`App listening at http://localhost:${port}`);
});