-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
79 lines (72 loc) · 1.81 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const express=require('express')
const mongoose=require('mongoose')
const quizRoute= require('./routes/quizRoute')
const clientRoute=require('./routes/clientRoute')
const QuizDetails= require('./models/quizdetails')
const userDetails=require('./models/login')
const app=express()
require('dotenv/config')
app.use('/api',quizRoute)
app.use('/quiz',clientRoute)
app.use(express.static(__dirname+'/css'))
app.set('view engine', 'ejs')
app.get('/',async (req,res)=>{
try{
res.render('login')
}
catch(err)
{
console.log("err");
}
})
app.get('/:userid/newquiz',async (req,res)=>{
try
{
const user= await userDetails.findOne({_id : req.params.userid},{password : 0});
console.log(user)
res.render('newquiz',{user : user})
}
catch(err)
{
res.send('no data')
}
})
app.get('/:userid/evaluation',async (req,res)=>{
try{
const user= await userDetails.findOne({_id : req.params.userid},{password : 0});
const quizDetails=await QuizDetails.find({authorEmail: user.mail})
res.render('evaluation',{quizDetails,user})
}
catch(err)
{
console.log(err)
}
})
app.get('/login',(req,res)=>{
res.render('login')
})
app.get('/signup',(req,res)=>{
res.render('signup')
})
app.get('/:userid',async (req,res)=>{
try
{
const user= await userDetails.findOne({_id : req.params.userid},{password : 0});
console.log(user)
res.render('quizall',{user : user})
}
catch(err)
{
res.send('no data')
}
})
app.get('/forgetpassword/resetme',(req,res)=>{
res.render('forgetpass')
})
mongoose.connect(process.env.DB_CONNECTION,{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false
})
app.listen(process.env.PORT || 3000 )