-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
29 lines (24 loc) · 808 Bytes
/
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
// launch express to serve files
const express = require('express');
const path = require('path');
const PORT = 3000;
const app = express();
app.set('view engine', 'ejs');
app.use('/resources/dev/flot', express.static('flot/source'));
app.use('/dist', express.static('dist'));
app.use('/*', (req, res, next) => {
if (req.originalUrl === '/') {
res.render(path.join(__dirname, './html/index'), { version: null, _apiUrl: `http://localhost:${PORT}/` });
} else {
next();
}
});
app.use('/', express.static(path.join(__dirname, './html')));
const apiPassthru = require('./apipassthru');
// pass through to api
app.use('/points', apiPassthru);
app.use('/gridpoints', apiPassthru);
app.use('/stations', apiPassthru);
app.use('/alerts', apiPassthru);
app.use('/products', apiPassthru);
app.listen(PORT);