-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (26 loc) · 734 Bytes
/
app.js
File metadata and controls
33 lines (26 loc) · 734 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
// LOAD ENV VARIABLES
require('dotenv').config();
// SET SERVER PORT
const PORT = process.env.PORT || 8000;
// REQUIRES
const bodyParser = require('body-parser');
const express = require('express');
const morgan = require('morgan');
const path = require('path');
// APP DECLARATION
const app = express();
// GENERAL MIDDLEWARE
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('build'));
// ROUTES
app.use('/api', require('./routes/api'));
app.get('/', (req, res) => {
let filepath = path.resolve('index.html');
res.sendFile(filepath);
});
// SERVER LISTEN
app.listen(PORT, err => {
console.log(err || `Express listening on port ${PORT}`);
});