-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
32 lines (25 loc) · 898 Bytes
/
index.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
30
31
32
// Application entry point
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
// Set up the express app
const app = express();
// Parse incoming requests data (https://github.com/expressjs/body-parser)
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Routing
require('./server/routes')(app);
// React routing
const authRoutes = require('./server/routes/auth');
app.use('/auth', authRoutes);
// Directories with static files
app.use(express.static('./server/static/'));
app.use(express.static('./client/dist/'));
// Setup a default catch-all route that sends back a welcome message in JSON format.
app.get('*', (req, res) => res.status(200).send({
message: 'Welcome. Nothing here.',
}));
// start the server
app.listen(8000, () => {
console.log('Server is running on http://localhost:8000');
});