forked from Sethfire/foxhole-war-map
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
36 lines (27 loc) · 892 Bytes
/
app.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
const express = require('express');
const warapi = require('./warapi.js');
const app = express();
// prefix starts with /
const endpoints = (prefix) => {
app.use(prefix, express.static('public'));
app.get(prefix, (request, response) => {
response.sendFile(__dirname + '/views/index.html');
});
app.get(prefix + '/api/dynamic', (request, response) => {
response.sendFile(__dirname + '/data/dynamic.json');
});
app.get(prefix + '/api/static', (request, response) => {
response.sendFile(__dirname + '/data/static.json');
});
app.get(prefix + '/api/regions', (request, response) => {
response.sendFile(__dirname + '/data/regions.json');
});
}
endpoints("/");
endpoints("/map");
const port = 3002;
app.listen(port, () => {
console.log(`App listening at ${port}`);
warapi.updateWarData();
setInterval(warapi.updateWarData, 60000);
});