-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
36 lines (32 loc) · 928 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
require("dotenv").config();
const express = require("express");
const mongoose = require("mongoose");
const cookieParser = require("cookie-parser");
const studentRouter = require("./routes/studentRoute");
const adminRouter = require("./routes/adminRoute");
const companyRouter = require("./routes/companyRoute");
const cors = require("cors");
const app = express();
const port = process.env.PORT;
// built-in middlewares
app.use(
cors({
origin: "http://localhost:3000",
credentials: true,
})
);
app.use(express.json());
app.use(cookieParser());
mongoose
.connect(process.env.MONGODB_URL, { useNewUrlParser: true })
.then((result) => {
app.listen(port, () => {
console.log("Connected to db and Server is up on the port : " + port);
});
})
.catch((err) => {
console.log(err);
});
app.use(studentRouter);
app.use(adminRouter);
app.use(companyRouter);