-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog.controller.js
More file actions
53 lines (47 loc) · 1.05 KB
/
blog.controller.js
File metadata and controls
53 lines (47 loc) · 1.05 KB
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
const httpStatus = require('http-status');
const blog = require('./blog.helper');
const { handleCatch } = require('../utils/common');
function search(req, res) {
blog.getBlogBySearch(req.body)
.then(blogs => {
return res.send(blogs);
})
.catch(error => handleCatch(error, res));
}
function get(req, res) {
blog.getAllBlogs()
.then(blogs => {
return res.send(blogs);
})
.catch(error => handleCatch(error, res));
}
function add(req, res) {
blog.addBlog(req.body)
.then(blog => {
return res.send(blog);
})
.catch(error => handleCatch(error, res));
}
function update(req, res) {
blog.updateBlog(req.body, req.params.id)
.then(blog => {
return res.send(blog);
})
.catch(error => handleCatch(error, res));
}
function remove(req, res) {
blog.removeBlog(req.params.id)
.then(blog => {
return res.send(blog);
})
.catch(error => {
return res.status(httpStatus.INTERNAL_SERVER_ERROR).send(error);
});
}
module.exports = {
search,
get,
add,
update,
remove,
};