-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (25 loc) · 859 Bytes
/
server.js
File metadata and controls
31 lines (25 loc) · 859 Bytes
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
// This file is used to server our static html file.
const express = require('express');
const path = require('path');
const compression = require('compression');
const favicon = require('serve-favicon');
const http = require('http');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
dotenv.config();
const port = process.env.PORT || 5000;
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(compression());
app.use(express.static('dist'));
// uncomment for favicon
// app.use(favicon(path.join(__dirname, 'favicon.ico')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, './dist/index.html'));
});
const server = http.createServer(app);
server.listen(port, (err) => {
if (err) console.error(err);
console.info('app running on port', port);
});