-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontroller.js
More file actions
30 lines (29 loc) · 906 Bytes
/
controller.js
File metadata and controls
30 lines (29 loc) · 906 Bytes
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
module.exports = {
getPlane: ( req, res, next ) => {
const dbInstance = req.app.get('db');
dbInstance.get_plane([req.params.id])
.then(plane => { res.status(200).send(plane); })
.catch( err => {
console.log(err);
res.status(500).send(err);
});
},
getPlanes: ( req, res, next ) => {
const dbInstance = req.app.get('db');
dbInstance.get_planes()
.then(planes => { res.status(200).send(planes); })
.catch( err => {
console.log(err);
res.status(500).send(err);
});
},
postPlane:(req, res, next ) => {
const dbInstance = req.app.get('db');
dbInstance.post_plane([req.body.planeType, req.body.passengerCount])
.then(planes => {res.status(200).send(planes)})
.catch( err => {
console.log(err);
res.status(500).send(err);
});
}
};