-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (23 loc) · 794 Bytes
/
app.js
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
var express = require('express'),
app = express(),
bodyParser = require('body-parser');
path = require('path');
var commentsRoutes = require('./custom-modules/routes_comments'),
otherRoutes = require('./custom-modules/routes_other')
// Allow parsing body from post requests
app.use(bodyParser.json());
// Import the routes
app.use(commentsRoutes);
app.use(otherRoutes);
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname+'/client/build/index.html'));
});
// Fallback route (404)
// app.use(function(req, res) {
// res.sendStatus(404);
// });
// Start backend server
const port = process.env.PORT || 5000;
app.listen(port, function() {
console.log(`Server running on port ${port} (http://localhost:${port}).`);
});