-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
31 lines (27 loc) · 843 Bytes
/
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
'use strict';
var express = require('express');
var request = require('request');
var fs = require('fs');
var path = require('path');
var packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json')));
var app = express();
app.use(express.static('dist/'));
app.get('/jetty/api/v1/status', function (req, res) {
request({
url: 'https://portal.imice.de/api1/rs/status',
headers: {
'User-Agent': 'ice-map ' + packageJson.version,
}
}).on('error', err => {
if (err.code === 'ENOTFOUND') {
console.warn(`Not found. Please check your connection and ensure you're using the onboard wifi.`);
res.sendStatus(404);
} else {
throw err;
}
}).pipe(res);
});
app.listen(9000, function (err) {
if (err) console.error(err);
else console.log('Listening on localhost:9000');
});