-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (34 loc) · 1018 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
const expresss = require("express");
const app=expresss();
const mongoose = require("mongoose");
const morgan = require("morgan")
const helmet = require("helmet");
const Studentrouter =require("./routes/student")
const dean =require("./routes/dean")
const cookieParser = require("cookie-parser");
const database = (module.exports = () => {
const connectionParams = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
try {
mongoose.connect(
'mongodb+srv://nikhilanand2432:[email protected]/?retryWrites=true&w=majority',
connectionParams
);
console.log("Database connected succesfully");
} catch (error) {
console.log(error);
console.log("Database connection failed");
}
});
database();
app.use(expresss.json());
app.use(cookieParser());
app.use(helmet());
app.use(morgan("common"));
app.use('/api', Studentrouter);
app.use('/api/dean', dean);
app.listen(8800,()=>{
console.log("ready");
})