-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (36 loc) · 1.11 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const morgan = require("morgan");
const cors = require("cors");
const app = express();
require("dotenv").config();
require("./config/dbconnection");
app.use(cors());
app.use(express.static(path.join(__dirname, "public")));
app.use(morgan("dev"));
app.use(express.urlencoded({ extended: true }));
app.use(bodyParser.json());
// app.use(bodyParser.urlencoded({ extended: true }));
// load schemas
const User = require("./models/User");
// Routes
app.use("/api/auth", require("./routes/api/authRouter"));
app.use("/api/index", require("./routes/api/indexRouter"));
// app.use(express.static(path.join(__dirname, 'client/build')))
// app.get('*', (req, res) => {
// res.sendFile(path.join(__dirname + '/client/build/index.html'))
// })
// app.get('*', (req, res) => {
// res.render('notfound');
// });
app.listen(process.env.PORT, err => {
if (err) {
console.log(err);
console.log("Error in running server");
return;
}
console.log(
`Server is up and running on http://localhost:${process.env.PORT}`
);
});