-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (32 loc) · 911 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
33
34
35
require("dotenv").config();
const express = require("express");
const cookieParser = require("cookie-parser");
const { connect } = require("mongoose");
const userRoute = require("./routes/userRouter");
const noteRoute = require('./routes/noteRouter')
const app = express();
// Database Connection
connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Database Connection established");
})
.catch((err) => {
console.log(err);
});
// middlewares
app.use(express.static("public"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use("/user", userRoute);
app.use("/", noteRoute);
app.set("view engine", "ejs");
// server configuration
const PORT = process.env.PORT || 8080;
app.listen(PORT, (err) => {
if (err) throw err;
console.log(`Server running on port ${PORT}`);
});