-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
106 lines (100 loc) · 2.13 KB
/
server.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const express = require('express');
const app = express();
const cors = require('cors');
const PORT = 8000;
app.use(cors());
const teams = {
'ireland': {
'country': 'Ireland',
'pool': 'Pool B'
},
'england': {
'country': 'England',
'pool': 'Pool D'
},
'scotland': {
'country': 'Scotland',
'pool': 'Pool B'
},
'wales': {
'country': 'Wales',
'pool': 'Pool C'
},
'france': {
'country': 'France',
'pool': 'Pool A'
},
'italy': {
'country': 'Italy',
'pool': 'Pool A'
},
'south africa': {
'country': 'South Africa',
'pool': 'Pool B'
},
'new zealand': {
'country': 'New Zealand',
'pool': 'Pool A'
},
'australia': {
'country': 'Australia',
'pool': 'Pool C'
},
'argentina': {
'country': 'Argentina',
'pool': 'Pool D'
},
'japan': {
'country': 'Japan',
'pool': 'Pool D'
},
'tonga': {
'country': 'Tonga',
'pool': 'Pool B'
},
'samoa': {
'country': 'Samoa',
'pool': 'Pool D'
},
'namibia': {
'country': 'Namibia',
'pool': 'Pool A'
},
'romania': {
'country': 'Romania',
'pool': 'Pool B'
},
'chile': {
'country': 'Chile',
'pool': 'Pool D'
},
'uruguay': {
'country': 'Uruguay',
'pool': 'Pool A'
},
'fiji': {
'country': 'Fiji',
'pool': 'Pool C'
},
'georgia': {
'country': 'Georgia',
'pool': 'Pool C'
},
'portugal': {
'country': 'Portugal',
'pool': 'Pool C'
},
'unknown': {
'pool': 'Unfortunately did not qualify for Rugby World Cup 2023'
}
}
app.get('/', (req, resp) => {
resp.sendFile(__dirname + '/index.html');
})
app.get('/api/:country', (req,res) => {
const countryName = req.params.country.toLowerCase();
teams[countryName] ? res.json(teams[countryName]) : res.json(teams['unknown']);
})
app.listen(process.env.PORT || PORT, () =>{
console.log(`Server running on port ${PORT}`);
})