-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
52 lines (41 loc) · 1.42 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const indexRouter = require('./routes/index');
const metricsRouter = require('./routes/metrics');
require('dotenv').config()
const db = require('./db')
db()
const app = express();
const compression = require('compression');
app.use(compression());
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.text());
// Cors
const cors = require('cors')
app.use(cors())
app.use('/', indexRouter);
app.use('/metrics', metricsRouter);
app.use(express.static(path.join(__dirname, './perfanalytics-dashboard/build')));
['/dashboard', '/dashboard/*'].forEach(p => {
app.get(p, (req, res) => {
res.sendFile(path.resolve(__dirname, './perfanalytics-dashboard', 'build', 'index.html'));
});
});
app.use(express.static(path.join(__dirname, './test-client-react/build')));
['/test', '/test/*'].forEach(p => {
app.get(p, (req, res) => {
res.sendFile(path.resolve(__dirname, './test-client-react', 'build', 'index.html'));
});
});
app.get('/perfanalytics.js', (req, res) => {
res.sendFile(path.resolve(__dirname, './perfanalytics-js', 'bundle.js'));
});
module.exports = app;