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",
* "submittedOn": 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),
)
}
module.exports = FragmentsRecommendations