-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (25 loc) · 809 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
const express = require("express");
const { noteController } = require("./routes/note.route");
const { userController } = require("./routes/user.route");
const { connection } = require("./config/db");
const { authentication } = require("./middlewares/authentication");
const cors = require('cors')
require("dotenv").config();
const PORT = process.env.PORT || 8080;
const app = express();
app.use(express.json());
app.get("/", (req, res) => {
res.status(200).send("Welcome to the notebook");
});
app.use(cors())
app.use("/user", userController);
app.use(authentication)
app.use("/note", noteController);
app.listen(PORT, async (req, res) => {
try {
await connection;
console.log(`Connected to ${PORT}`);
} catch (err) {
console.log(`Something went wrong to connect to ${PORT}`);
}
});