publications

This module contains handlers for the "publications" route.
Source:

Methods

(async, inner) createPublication(req, res)

Source:
Handles a POST request, which will create a publication in the database using the endpoint /publications.
Validation rules:
- at least one author,
- title needs to be at least 3 characters,
- description needs to be at least 5 characters,
- summary needs to be at least 5 characters,
- citedBy needs to be an integer value of 0 or greater
Parameters:
Name Type Description
req request object - publication in body (see Publication model)
res response object
Returns:
  • 201: the publication has been created
  • 400: the publication given in the request fails some validation also @see validationMiddlewares
  • 404: no team was found to associate the publication with

(async, inner) deletePublication(req, res)

Source:
Handles a DELETE request to delete a publication by the mongo object id on the endpoint /publications/:id.
Parameters:
Name Type Description
req request object - the publication id given in the url
res response object
Returns:
  • 200: publication deleted successfully
  • 404: publication not found
  • 400: error deleting publication

(async, inner) readAllPublicationsByTeam(req, res)

Source:
To Do:
  • filter by other fields like year passed in through req.query
Handles a GET request, which will retrieve all publications by team in the endpoint /publications/team/:team_id.
Parameters:
Name Type Description
req request object - team id given in the url
res response object - a list of publications (see Publications model)
Returns:
  • 200: a list of publications by the given team id
  • 400: given team id is not in a valid hexadecimal format
  • 404: the specified team or publication was not found

(async, inner) readPublication(req, res)

Source:
Handles a GET request, which will retrieve the specified publication in the database with the given mongo object id in the endpoint /publications/:id
Parameters:
Name Type Description
req request object - including the publication id given in the url
res response object - publication (see Publications model)
Returns:
  • 200: the specified publication was found
  • 400: given publication id is not in a valid hexadecimal format
  • 404: no publications were found

(async, inner) updatePublication(req, res)

Source:
Handles a PATCH request, which represents updating a specific publication, on the /publications/:id endpoint.
Parameters:
Name Type Description
req request object - the publication id given in the url, publication in body (see Publication model)
res response object - updated publication
Returns:
  • 200: the newly updated publication
  • 404: publication not found
  • 422: error in the request object, unable to update publication