-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (29 loc) · 851 Bytes
/
server.js
File metadata and controls
34 lines (29 loc) · 851 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
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const { connect } = require("./server/database/database.js");
const cors = require('cors');
// Setup express app
const app = express();
// parse application/x-www-form-urlencoded
// Config dotev
require('dotenv').config({
path: './config/config.env'
})
app.use(
bodyParser.urlencoded({ extended: false })
)
// parse application/json
app.use(
bodyParser.json()
)
app.use(
cors()
)
connect();
require('./server/routes')(app);
app.use(bodyParser.json());
// Specify the Port where the backend server can be accessed and start listening on that port
const port = process.env.PORT || 5000;
app.use(express.static(path.join(__dirname, 'build')));
app.listen(port, () => console.log(`Server up and running on port ${port}.`));