-
Notifications
You must be signed in to change notification settings - Fork 1
/
activity.controller.js
44 lines (41 loc) · 1.09 KB
/
activity.controller.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
const Activity = require("./activity.model.js");
exports.findAll = (req, res) => {
Activity.getAll((err, data) => {
if (err)
res.status(500).send({
message:
err.message || "Some error occurred while retrieving."
});
else res.send(data);
});
};
exports.findBySupply = (req, res) => {
Activity.getBySupply(req.params.supply, (err, data) => {
if (err) {
if (err.kind === "not_found") {
res.status(404).send({
message: `Not found with supply ${req.params.supply}.`
});
} else {
res.status(500).send({
message: "Error retrieving " + req.params.supply
});
}
} else res.send(data);
});
};
exports.findTagsById = (req, res) => {
Activity.getTagsById(req.params.id, (err, data) => {
if (err) {
if (err.kind === "not_found") {
res.status(404).send({
message: `Not found with supply ${req.params.id}.`
});
} else {
res.status(500).send({
message: "Error retrieving " + req.params.id
});
}
} else res.send(data);
});
};