-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
29 lines (22 loc) · 840 Bytes
/
server.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
const express = require("express");
const app = express();
const cors = require('cors');
const path = require("path");
const bodyParser = require("body-parser");
//Middleware
app.use(cors());
app.use(bodyParser.json());
//Serving React Build via Express.js
app.use('/', express.static(path.join(__dirname, "client", "build")));
const authRoute = require('./routes/authRoutes');
app.use("/api/auth/", authRoute);
const stockRoute = require('./routes/stockRoutes');
app.use("/api/stocks/", stockRoute);
const portfolioRoute = require('./routes/portfolioRoutes');
app.use("/api/portfolio/", portfolioRoute);
//Catch All
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Server started on port ${port}`));