-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathapp.js
36 lines (30 loc) · 966 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 dotenv = require('dotenv');
const express = require('express');
const app = express();
dotenv.config();
const github = require('./server/routes/api/github');
const buildbot = require('./server/routes/api/buildbot');
const testman = require('./server/routes/api/testman');
const PORT = process.env.PORT || 5000;
const path = require('path');
const dev = app.get('env') !== 'production';
//settings for production Environment
if (!dev) {
app.disable('x-powered-by');
// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'client/build')));
}
//API calls to GitHub API
app.use('/api/github', github);
//API calls to BuildBot Endpoints
app.use('/api/buildbot', buildbot);
//API calls to Testman Endpoints
app.use('/api/testman', testman);
if (!dev) {
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/build/index.html'));
});
}
app.listen(PORT, () => {
console.log('server started');
});