Newer
Older
const bodyParser = require('body-parser')
const FragmentsRecommendations = app => {
app.use(bodyParser.json())
const basePath =
'/api/collections/:collectionId/fragments/:fragmentId/recommendations'
const routePath = './routes/fragmentsRecommendations'
const authBearer = app.locals.passport.authenticate('bearer', {
session: false,
})
/**
* @api {post} /api/collections/:collectionId/fragments/:fragmentId/recommendations Create a recommendation on a fragment
* @apiGroup FragmentsRecommendations
* @apiParam {collectionId} collectionId Collection id
* @apiParam {fragmentId} fragmentId Fragment id
* @apiParamExample {json} Body
* {
* "recommendation": "accept", [acceptedValues: accept, revise, etc.],
* "comments":
* [
* {
* "content": "A very nice manuscript",
* "public": true
* "files":
* [
* {
* "id": "111-22-333",
* "name": "file.pdf",
* "size": 104232
* }
* ]
* }
* ],
* "recommendationType": "review" [acceptedValues: review, editorRecommendation]
* }
* @apiSuccessExample {json} Success
* HTTP/1.1 200 OK
* {
* "id": "7b2431af-210c-49f9-a69a-e19271066ebd",
* "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6",
* "createdOn": 1525428890167,
* "updatedOn": 1525428890167,
* "recommendation": "accept", [acceptedValues: accept, revise, etc.],
* "comments":
* [
* {
* "content": "A very nice manuscript",
* "public": true
* "files":
* [
* {
* "id": "111-22-333",
* "name": "file.pdf",
* "size": 104232
* }
* ]
* }
* ],
* "recommendationType": "review" [acceptedValues: review, editorRecommendation]
* @apiErrorExample {json} Invite user errors
* HTTP/1.1 403 Forbidden
* HTTP/1.1 400 Bad Request
* HTTP/1.1 404 Not Found
* HTTP/1.1 500 Internal Server Error
*/
app.post(
basePath,
authBearer,
require(`${routePath}/post`)(app.locals.models),
)
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* @api {patch} /api/collections/:collectionId/fragments/:fragmentId/recommendations/:recommendationId Create a recommendation on a fragment
* @apiGroup FragmentsRecommendations
* @apiParam {collectionId} collectionId Collection id
* @apiParam {fragmentId} fragmentId Fragment id
* @apiParam {recommendationId} recommendationId Recommendation id
* @apiParamExample {json} Body
* {
* "recommendation": "accept", [acceptedValues: accept, revise, etc.],
* "comments":
* [
* {
* "content": "A very nice manuscript",
* "public": true
* "files":
* [
* {
* "id": "111-22-333",
* "name": "file.pdf",
* "size": 104232
* }
* ]
* }
* ],
* "recommendationType": "review" [acceptedValues: review, editorRecommendation]
* }
* @apiSuccessExample {json} Success
* HTTP/1.1 200 OK
* {
* "id": "7b2431af-210c-49f9-a69a-e19271066ebd",
* "userId": "4c3f8ee1-785b-4adb-87b4-407a27f652c6",
* "createdOn": 1525428890167,
* "updatedOn": 1525428890167,
* "recommendation": "accept", [acceptedValues: accept, revise, etc.],
* "comments":
* [
* {
* "content": "A very nice manuscript",
* "public": true
* "files":
* [
* {
* "id": "111-22-333",
* "name": "file.pdf",
* "size": 104232
* }
* ]
* }
* ],
* "recommendationType": "review" [acceptedValues: review, editorRecommendation]
* }
* @apiErrorExample {json} Invite user errors
* HTTP/1.1 403 Forbidden
* HTTP/1.1 400 Bad Request
* HTTP/1.1 404 Not Found
* HTTP/1.1 500 Internal Server Error
*/
app.patch(
`${basePath}/:recommendationId`,
authBearer,
require(`${routePath}/patch`)(app.locals.models),
)
}
module.exports = FragmentsRecommendations