forked from topcoder-archive/submissions-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReviewController.js
More file actions
71 lines (63 loc) · 1.48 KB
/
Copy pathReviewController.js
File metadata and controls
71 lines (63 loc) · 1.48 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Review Controller
*/
const ReviewService = require('../services/ReviewService')
const helper = require('../common/helper')
/**
* Get review
* @param req the http request
* @param res the http response
*/
function * getReview (req, res) {
res.json(yield ReviewService.getReview(req.authUser, req.params.reviewId))
}
/**
* List reviews from ES
* @param req the http request
* @param res the http response
*/
function * listReviews (req, res) {
const data = yield ReviewService.listReviews(req.query)
helper.setPaginationHeaders(req, res, data)
}
/**
* Create review
* @param req the http request
* @param res the http response
*/
function * createReview (req, res) {
res.json(yield ReviewService.createReview(req.authUser, req.body))
}
/**
* Update review
* @param req the http request
* @param res the http response
*/
function * updateReview (req, res) {
res.json(yield ReviewService.updateReview(req.authUser, req.params.reviewId, req.body))
}
/**
* Patch review
* @param req the http request
* @param res the http response
*/
function * patchReview (req, res) {
res.json(yield ReviewService.patchReview(req.authUser, req.params.reviewId, req.body))
}
/**
* Delete review
* @param req the http request
* @param res the http response
*/
function * deleteReview (req, res) {
yield ReviewService.deleteReview(req.params.reviewId)
res.status(204).send()
}
module.exports = {
getReview,
listReviews,
createReview,
updateReview,
patchReview,
deleteReview
}