-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (33 loc) · 925 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
30
31
32
33
34
35
36
37
38
39
const path = require("path");
const express = require("express");
const dotenv = require("dotenv");
const morgan = require("morgan");
const ejs = require("ejs");
const indexRouter = require("./routes/index");
const finalRouter = require('./routes/leaderboard');
const connectDB = require("./config/db");
dotenv.config();
connectDB();
const app = express();
app.use(
express.urlencoded({
extended: false,
})
);
if (process.env.NODE_ENV === "development") {
app.use(morgan("dev"));
}
app.set("view engine", ".ejs");
app.set("views", "./views/");
app.use(express.static(path.join(__dirname, "public")));
app.get('/', function(req, res) {
console.log('hi')
res.sendFile(path.join(__dirname, 'react/public/index.html'));
});
app.use(indexRouter);
app.use(finalRouter);
const PORT = process.env.PORT || 3001;
app.listen(
PORT,
console.log(`Server running in ${process.env.NODE_ENV} mode in port ${PORT}`)
);