Skip to content

Server | Endpoints

Mitchell Mastromonaco edited this page Apr 15, 2020 · 27 revisions

Adding new endpoints

Endpoints in express (and in general) follow certain guidelines. Therefore, one must follow these guidelines to make proper endpoints. The format for the endpoint is as follows :

  1. The beginning is standardized by starting with /api.
  2. Add the name of your entity followed by an s. For example, /tasks or /taskPrioritys.
  3. Add the name of what the endpoint does. For example, /create, /update or /list.
  4. (Optional) Add any parameters required. This step may be repeated. For example, /:taskId or /:taskId/:attr.
Utilities end-points:
Database end-points:
annotations
  • /api/annotations
    • /api/annotations/create
    • /api/annotations/clone/:annotationId
    • /api/annotations/update/:annotationId
    • /api/annotations/delete/:annotationId
    • /api/annotations/list
    • /api/annotations/list/:attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/annotations/getBase
    • /api/annotations/get/getEmpty
    • /api/annotations/get/:annotationId([0-9]+)
    • /api/annotations/get/:annotationId([0-9]+)/:attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/annotations/get
    • /api/annotations/get/:attr([a-zA-Z][a-zA-Z0-9]+)
images
  • /api/images
    • /api/images/create
    • /api/images/createNew
    • /api/images/createCli
    • /api/images/update/:imageId
    • /api/images/updateFile/:imageId
    • /api/images/updatePreprocessing/:imageId
    • /api/images/delete/:imageId
    • /api/images/list
    • /api/images/list/attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/images/gallery
    • /api/images/get/:imageId([0-9]+)
    • /api/images/get/:imageId([0-9]+)/attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/images/get
    • /api/images/get/:attr([a-zA-Z][a-zA-Z0-9]+)
submission events
  • /api/submissionEvents
    • /api/submissionEvents/list
    • /api/submissionEvents/list/:attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/submissionEvents/get/:id([0-9]+)
    • /api/submissionEvents/get/:id([0-9]+)/attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/submissionEvents/get
    • /api/submissionEvents/get/:attr([a-zA-Z][a-zA-Z0-9]+)
task
  • /api/tasks
    • /api/tasks/create
    • /api/tasks/update/:taskId
    • /api/tasks/delete/:taskId
    • /api/tasks/submit/:taskId
    • /api/tasks/list
    • /api/tasks/list/:attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/tasks/gallery/:userId
    • /api/tasks/get/:taskId([0-9]+)
    • /api/tasks/get/:taskId([0-9]+)/attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/tasks/get
    • /api/tasks/get/:attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/tasks/get/next/:userId
task prioritys
  • /api/taskPrioritys
    • /api/taskPrioritys/create
    • /api/taskPrioritys/update/:taskPriorityId
    • /api/taskPrioritys/delete/:taskPriorityId
    • /api/taskPrioritys/assign/
    • /api/taskPrioritys/get/tasksBundles
task types
  • /api/taskTypes
    • /api/taskTypes/create
    • /api/taskTypes/update/:taskTypeId
    • /api/taskTypes/delete/:taskTypeId
    • /api/taskTypes/list
    • /api/taskTypes/list/:attr
    • /api/taskTypes/get/:taskTypeId([0-9]+)
    • /api/taskTypes/get/:taskTypeId([0-9]+)/attr([a-zA-Z][a-zA-Z0-9]+)
    • /api/taskTypes/get
    • /api/taskTypes/get/:attr([a-zA-Z][a-zA-Z0-9]+)
users
widgets
  • /api/widgets
    • /api/widgets/create
    • /api/widgets/update/:widgetId
    • /api/widgets/delete/:widgetId

Bugtracker

Login

Users

  • POST /api/users/create

    Add a user to the database. This operation needs administrator privilege.
    Request body:
    • firstName [str]: User's first name.
    • lastName [str]: User's last name.
    • email [str]: User's email. It's also the ID used by the user to authenticate to the server.
    • password [str]: User's password. As of now, the CLI doesn't encrypt the password.
    • isAdmin [bool]: Set the role of the user (deprecated since more role have been added).
    Return:
    The created user.

Put Requests

  • PUT /api/users/update/:userId

    Modify a user in the database.
    Request parameters:
    • userId [int]: The index of the user to modify.
    Request body:
    • firstName [str OPTIONAL]: User's first name.
    • lastName [str OPTIONAL]: User's last name.
    • email [str OPTIONAL]: User's email. It's also the ID used by the user to authenticate to the server.
    • password [str OPTIONAL]: User's password. As of now, the CLI doesn't encrypt the password.
    • isAdmin [bool OPTIONAL]: Set the role of the user (deprecated since more role have been added).
    Return:
    The modified user.

Delete Requests

  • DELETE /api/users/delete/:userId

    Delete a user in the database.
    Request parameters:
    • userId [int]: The index of the user to delete.
    Return:
    The deleted user.

Get Requests

  • GET /api/users/get/:userId/:attr

    Fetch a user from the database.

    Request parameters:
    • userId [int]: The index of the user to modify.

    • attr [string]: The attribute to fetch from the selected user. If none is provided the entire User entity is transmitted. See the return section for more information.

    • undefined: the entire User entity.

    • proto: the ProtoUser prototype.

  • GET /api/users/get/:attr

    Fetch several users from the database.

    Request parameters:
    • attr [string]: The attribute to fetch from the selected users. If none is provided the entire User entities are transmitted. See the return section for more information.
    Request body:
    • ids [list]: The indexes of the users to fetch.
    Return:

    The returned object depend on the attr requests parameters:

    • undefined: A list of entire User entities.
    • proto: A list of ProtoUser prototype.

Clone this wiki locally