-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (26 loc) · 799 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
const express = require("express");
const app = express();
const userRouter = require("./src/routes/userRoutes");
const noteRouter = require("./src/routes/noteRoutes");
const dotenv= require("dotenv");
const path = require("path")
const cors= require("cors");
dotenv.config({path: path.resolve(__dirname, "./.env")});
const mongoose = require("mongoose");
app.use(express.json());
app.use(cors());
app.use("/users", userRouter)
app.use("/note", noteRouter)
app.get("/", (req, res) => {
res.send("Notes API!!");
})
const PORT = process.env.PORT || 5000;
mongoose.connect(process.env.MONGO_URL)
.then(() => {
app.listen(PORT, () => {
console.log("Server started on port no. "+ PORT);
});
})
.catch((error) => {
console.log(error);
})