generated from WebJamApps/CollegeLutheran
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (19 loc) · 838 Bytes
/
server.js
File metadata and controls
22 lines (19 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* eslint-disable @typescript-eslint/no-var-requires */
require('dotenv').config();
const path = require('path');
const express = require('express');
const enforce = require('express-sslify');
const app = express();
let port = Number(process.env.PORT);
if (process.env.NODE_ENV === 'test') port += 10;
/* istanbul ignore if */
if (process.env.NODE_ENV === 'production') app.use(enforce.HTTPS({ trustProtoHeader: true }));
app.use(express.static(path.normalize(path.join(__dirname, 'dist'))));
app.use('/', express.static(path.normalize(path.join(__dirname, 'dist'))));
app.get('/*', (request, response) => {
response.sendFile(path.normalize(path.join(__dirname, 'dist/index.html')));
});
app.listen(port, () => {
console.log(`Magic happens on port ${process.env.PORT}`); // eslint-disable-line no-console
});
module.exports = app;