-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (49 loc) · 1.33 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import dotenv from "dotenv";
import express from "express";
import cors from "cors";
import fetch from "node-fetch";
dotenv.config();
const app = express();
app.use(cors());
const API_URL_TEMP = "https://football-forecast.herokuapp.com";
app.get("/get_dates/", async function (req, res, next) {
const response = await fetch(`http://gatewaylambda.space:10500/get_dates/`, {
method: "GET",
}).then((res) => res.json());
res.json(response);
});
app.get("/get_teams/", async function (req, res, next) {
const response = await fetch(
`${process.env.MORACLE_API_BASE_URL}/get_teams`,
{
method: "GET",
}
).then((res) => res.json());
res.json(response);
});
app.get("/get_matches/:date", async function (req, res, next) {
const mockData = [
{
homeTeam: "Congo",
visitorTeam: "Poland",
startDate: new Date().toISOString(),
stadium: "Ahmad Bin Ali Stadium",
},
];
res.json(mockData);
});
app.get("/predict/football/:teams", async function (req, res) {
if (!req.params.teams) {
return res.json();
}
const response = await fetch(
`${API_URL_TEMP}/predict/football/${req.params.teams}`,
{
method: "GET",
}
).then((res) => res.json());
return res.json(response);
});
app.listen(5463, function () {
console.log("CORS-enabled web server listening on port 80");
});