Staging all basic files.

This commit is contained in:
Patrick Fic
2019-12-03 16:05:34 -07:00
parent 16bd6c3f8a
commit 8bcb4516c5
21 changed files with 10634 additions and 9323 deletions

31
server.js Normal file
View File

@@ -0,0 +1,31 @@
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const path = require('path');
var enforce = require('express-sslify');
if (process.env.NODE_ENV !== 'production') require('dotenv').config();
const app = express();
const port = process.env.PORT || 5000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(enforce.HTTPS({ trustProtoHeader: true }));
app.use(cors());
if (process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, 'client/build')));
app.get('/service-worker.js', (req, res) => {
res.sendFile(path.resolve(__dirname, '..', 'build', 'service-worker.js'));
});
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
}
app.listen(port, error => {
if (error) throw error;
console.log('Server running on port ' + port);
});