-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (40 loc) · 1.12 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const https = require('https')
const fs = require('fs')
const express = require('express')
const env = process.env
var app = express()
/*
Trust proxy in case needed for server like heroku, etc...
*/
app.set('trust proxy', true)
app.set('x-powered-by', false)
/**
* IMPORTANT: Application HAS to respond to GET /health with status 200
* for OpenShift health monitoring
*/
app.use('/health', (req, res) => {
res.status(200).send('Server is running and healthy.');
})
/*
Serve static assets
*/
app.use('/static', express.static('dist/static', {index: false}))
//if this route catches, then the asset could not be found
app.use('/static/*', (req, res) => {
res.status(404).send('We cannot find what you are looking for.')
})
/*
Send request to the app, let it deal with 404s, etc
*/
app.use((req, res) => {
res.sendFile(__dirname + '/dist/index.html')
})
/*
Startup app
*/
// app.listen(env.NODE_PORT || 3000, env.NODE_IP || 'localhost', function () {
// console.log(`Application worker ${process.pid} started...`)
// })
app.listen(env.PORT || 3000, function () {
console.log(`Application worker ${process.pid} started...`)
})