-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
35 lines (30 loc) · 1.29 KB
/
routes.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
import express from 'express'
const router = express.Router();
import TimeTable from './models.js'
router.get('/gdsc', async (req, res) => {
try {
const subscribers = await TimeTable.find({id:req.query.id})
// console.log(subscribers[0].tt[0][1])
res.json(subscribers[0].tt[req.query.day])
} catch (err) {
res.status(500).json({ message: err.message })
}
})
router.post('/add', async (req, res) => {
const timetable = new TimeTable({
id: req.body.id,
tt:[["MEP","DCS","DSP","ELE-A","DSDV","DSDV TUT", "TUT"],["5B1 DSP LAB/ 5B2 HDL LAB","5B1 DSP LAB/ 5B2 HDL LAB","5B1 DSP LAB/ 5B2 HDL LAB","ELE-B","DSP","DSP TUT","TUT"],["DSP","DCS","MEP","ELE-A","5B2-DSP LAB / 5B3 HDL LAB","5B2-DSP LAB / 5B3 HDL LAB","5B2-DSP LAB / 5B3 HDL LAB"],["DCS","DSDV","ET","ELE-B","MEP","MEP TUT"],["DSDV","DSP","ET","ELE-B","5B3 DSP LAB/ 5B1 HDL LAB","5B3 DSP LAB/ 5B1 HDL LAB","5B3 DSP LAB/ 5B1 HDL LAB"],["ELE-A","DCS","DCS TUT"]]
})
try {
const TimeTable = await timetable.save()
res.status(201).json(TimeTable)
res.send("done")
} catch (err) {
res.status(400).json({ message: err.message })
}
})
router.get('/',(req,res)=>{
console.log("homepage");
res.send("welcome to GDSC APP");
});
export default router;