-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (26 loc) · 728 Bytes
/
server.js
File metadata and controls
36 lines (26 loc) · 728 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
32
33
34
35
36
'use strict';
const express = require('express');
const morgan = require('morgan');
const path = require('path');
const port = process.env.PORT || 8000;
const app = express();
app.disable('x-powered-by');
switch (app.get('env')) {
case 'development':
app.use(morgan('dev'));
break;
case 'production':
app.use(morgan('short'));
break;
default:
}
// Expose public directory to client
app.use(express.static(path.join(__dirname, 'public')));
// Any other pages refer to index.html
app.use((_req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.listen(port, () => {
console.log('Listening on port', port); // eslint-disable-line no-console
});
module.exports = app;