-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (40 loc) · 1.15 KB
/
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
36
37
38
39
40
41
42
43
44
45
// const mongoose=require("mongoose");
// mongoose.connect("mongodb://127.0.0.1:27017/user_managment_system")
// .then(()=>{
// console.log("mongo connected")
// })
// .catch((err)=>{
// console.log(err)
// })
const mongoose=require('mongoose');
mongoose.set('strictQuery',false);
const port=5000 || process.env.PORT;
// const connectDB=async()=>{
// try{
// const conn=await mongoose.connect(process.env.MONGODB_URI);
// console.log(`Database connected: ${conn.connection.host}`);
// }
// catch(err){
// console.log(err);
// }
// }
mongoose.connect("mongodb+srv://anmolraj029:[email protected]/PriceComparator")
.then(()=>{
console.log("mongo connected")
})
.catch((err)=>{
console.log(err)
})
const express=require("express")
const app=express()
const bodyParser=require("body-parser")
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:true}))
app.set('view engine','ejs')
app.set('views','./views/users')
//for user routes
const UserRoutes=require('./routes/UserRoutes')
app.use('/',UserRoutes.user_route)
app.listen(port,()=>{
console.log("server is running");
})