Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

API Reference

Vlad White edited this page Jun 16, 2023 · 3 revisions

The Auth Route provides endpoints for managing auth-related operations.

Login

Endpoint: /auth/login

Method: POST

Description: Logs in a user and returns an authentication token.

Request Body:

Parameter Type Required Description
username string Optional User's username
email string Optional User's email
password string Required User's password

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "Username is required",
            "param": "username",
            "location": "body"
          },
          {
            "msg": "Email is required",
            "param": "email",
            "location": "body"
          },
          {
            "msg": "Password is required",
            "param": "password",
            "location": "body"
          }
        ]
      }
      
  • 401 Unauthorized

    • Response Body:

      {
        "error": "Invalid username or password"
      }
      
    • Response Body:

      {
        "error": "Invalid password"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "token": "string"
      }
      

Logout

Endpoint: /auth/logout

Method: POST

Description: Logs out the currently authenticated user.

Error Responses:

  • 500 Internal Server Error
    • Response Body:
      {
        "message": "Failed to logout"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "Logout successful"
      }
      

Register

Endpoint: /auth/register

Method: POST

Description: Registers a new user and returns an authentication token.

Request Body:

Parameter Type Required Description
username string required User's username
email string required User's email
password string required User's password

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "Username is required",
            "param": "username",
            "location": "body"
          },
          {
            "msg": "Email is required",
            "param": "email",
            "location": "body"
          },
          {
            "msg": "Password is required",
            "param": "password",
            "location": "body"
          }
        ]
      }
      
  • 401 Unauthorized

    • Response Body:
      {
        "message": "User already exists based on the data provided"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "token": "string"
      }
      

The Users Route provides endpoints for managing user-related operations.

Add User

Endpoint: /users/add/user

Method: POST

Description: Adds a new user to the system.

Request Body:

Parameter Type Required Description
username string Required User's username
email string Required User's email
password string Required User's password

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "Username is required",
            "param": "username",
            "location": "body"
          },
          {
            "msg": "Email is required",
            "param": "email",
            "location": "body"
          },
          {
            "msg": "Password is required",
            "param": "password",
            "location": "body"
          }
        ]
      }
      
  • 401 Unauthorized

    • Response Body:
      {
        "message": "User already exists based on the data provided"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "userInstance": {
          "uuid": "string",
          "username": "string",
          "ekoTag": "string",
          "email": "string",
          "password": "string",
          "joinedDate": "string",
          "followedInterests": [],
          "followers": [],
          "following": []
        }
      }
      

Edit User

Endpoint: /users/edit/user/:uuid

Method: PUT

Description: Edits an existing user.

Path Parameters:

Parameter Type Required Description
uuid string Required User's UUID

Request Body:

Include any fields that need to be updated for the user.

Error Responses:

  • 404 Not Found

    • Response Body:
      {
        "error": "User not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "updatedUser": {
          "uuid": "string",
          "username": "string",
          "ekoTag": "string",
          "email": "string",
          "password": "string",
          "joinedDate": "string",
          "followedInterests": [],
          "followers": [],
          "following": []
        }
      }
      

Remove User

Endpoint: /users/remove/user/:uuid

Method: DELETE

Description: Removes a user from the system.

Path Parameters:

Parameter Type Required Description
uuid string Required User's UUID

Error Responses:

  • 401 Unauthorized

    • Response Body:
      {
        "error": "Invalid user"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The user {uuid} has been removed successfully"
      }
      

Fetch User

Endpoint: /users/fetch/user/:uuid

Method: GET

Description: Fetches a user from the system.

Path Parameters:

Parameter Type Required Description
uuid string Required User's UUID

Error Responses:

  • 404 Not Found

    • Response Body:
      {
        "error": "User not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "user": {
          "uuid": "string",
          "username": "string",
          "ekoTag": "string",
          "email": "string",
          "password": "string",
          "joinedDate": "string",
          "followedInterests": [],
          "followers": [],
          "following": []
        }
      }
      

Fetch Users

Endpoint: /users/fetch/users

Method: GET

Description: Fetches all users from the system.

Error Responses:

  • 404 Not Found

    • Response Body:
      {
        "error": "Users not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "users": [
          {
            "uuid": "string",
            "username": "string",
            "ekoTag": "string",
            "email": "string",
            "password": "string",
            "joinedDate": "string",
            "followedInterests": [],
            "followers": [],
            "following": []
          }
        ]
      }
      

Add Follower

Endpoint: /users/add/follower

Method: POST

Description: Adds a follower to a user.

Request Body:

Parameter Type Required Description
userUUID string Required User's UUID
targetUUID string Required Target user's UUID

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "User uuid is required",
            "param": "userUUID",
            "location": "body"
          },
          {
            "msg": "Target uuid is required",
            "param": "targetUUID",
            "location": "body"
          }
        ]
      }
      
  • 404 Not Found

    • Response Body:
      {
        "error": "User not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The follower {targetUUID} has been added to User {userUUID} successfully"
      }
      

Remove Follower

Endpoint: /users/remove/follower

Method: DELETE

Description: Removes a follower from a user.

Request Body:

Parameter Type Required Description
userUUID string Required User's UUID
targetUUID string Required Target user's UUID

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "User uuid is required",
            "param": "userUUID",
            "location": "body"
          },
          {
            "msg": "Target uuid is required",
            "param": "targetUUID",
            "location": "body"
          }
        ]
      }
      
  • 404 Not Found

    • Response Body:
      {
        "error": "User not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The follower {targetUUID} has been removed from User {userUUID} successfully"
      }
      

Fetch Followers

Endpoint: /users/fetch/followers/:uuid

Method: GET

Description: Fetches the followers of a user.

Path Parameters:

Parameter Type Required Description
uuid string Required User's UUID

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "User uuid is required",
            "param": "uuid",
            "location": "params"
          }
        ]
      }
      
  • 404 Not Found

    • Response Body:
      {
        "error": "User not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "followerList": [],
        "followerCount": 0
      }
      

Fetch Following

Endpoint: /users/fetch/following/:uuid

Method: GET

Description: Fetches the users followed by a user.

Path Parameters:

Parameter Type Required Description
uuid string Required User's UUID

Error Responses:

  • 400 Bad Request

    • Response Body:
      {
        "error": [
          {
            "msg": "User uuid is required",
            "param": "uuid",
            "location": "params"
          }
        ]
      }
      
  • 404 Not Found

    • Response Body:
      {
        "error": "User not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "followingList": [],
        "followingCount": 0
      }
      

The Interests Route provides endpoints for managing interest-related operations.

Add Group

Endpoint: /interests/add/group

Method: POST

Description: Adds a new group to the system.

Request Body:

Parameter Type Required Description
name string Required Group's name
description string Required Group's description

Error Responses:

  • 400 Bad Request
    • Response Body:
      {
        "error": [
          {
            "msg": "Name is required",
            "param": "name",
            "location": "body"
          },
          {
            "msg": "Description is required",
            "param": "description",
            "location": "body"
          }
        ]
      }
      
  • 401 Unauthorized
    • Response Body:
      {
        "error": "Invalid group"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "groupInstance": {
          "uuid": "string",
          "name": "string",
          "description": "string",
          "interests": []
        }
      }
      

Edit Group

Endpoint: /interests/edit/group/:uuid

Method: PUT

Description: Edits an existing group.

Path Parameters:

Parameter Type Required Description
uuid string Required Group's UUID

Request Body:

Include any fields that need to be updated for the group.

Error Responses:

  • 404 Not Found
    • Response Body:
      {
        "error": "Group not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "updatedGroup": {
          "uuid": "string",
          "name": "string",
          "description": "string",
          "interests": []
        }
      }
      

Remove Group

Endpoint: /interests/remove/group/:uuid

Method: DELETE

Description: Removes a group from the system.

Path Parameters:

Parameter Type Required Description
uuid string Required Group's UUID

Error Responses:

  • 401 Unauthorized
    • Response Body:
      {
        "error": "Invalid group"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The group {uuid} has been removed successfully"
      }
      

Fetch Group

Endpoint: /interests/fetch/group/:uuid

Method: GET

Description: Fetches a group from the system.

Path Parameters:

Parameter Type Required Description
uuid string Required Group's UUID

Error Responses:

  • 404 Not Found
    • Response Body:
      {
        "error": "Group not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "group": {
          "uuid": "string",
          "name": "string",
          "description": "string",
          "interests": []
        }
      }
      

Fetch Groups

Endpoint: /interests/fetch/groups

Method: GET

Description: Fetches all groups from the system.

Error Responses:

  • 404 Not Found
    • Response Body:
      {
        "error": "Groups not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "groups": [
          {
            "uuid": "string",
            "name": "string",
            "description": "string",
            "interests": []
          }
        ]
      }
      

Add Interest

Endpoint: /interests/add/interest

Method: POST

Description: Adds a new interest to the system.

Request Body:

Parameter Type Required Description
name string Required Interest's name
description string Required Interest's description
group string Required Interest's group

Error Responses:

  • 400 Bad Request
    • Response Body:
      {
        "error": [
          {
            "msg": "Name is required",
            "param": "name",
            "location": "body"
          },
          {
            "msg": "Description is required",
            "param": "description",
            "location": "body"
          },
          {
            "msg": "Group is required",
            "param": "group",
            "location": "body"
          }
        ]
      }
      
  • 401 Unauthorized
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "interestInstance": {
          "uuid": "string",
          "name": "string",
          "description": "string",
          "group": "string",
          "followers": []
        }
      }
      

Edit Interest

Endpoint: /interests/edit/interest/:uuid

Method: PUT

Description: Edits an existing interest.

Path Parameters:

Parameter Type Required Description
uuid string Required Interest's UUID

Request Body:

Include any fields that need to be updated for the interest.

Error Responses:

  • 404 Not Found

    • Response Body:
      {
        "error": "Interest not found"
      }
      
  • 500 Internal Server Error

    • Response Body:
      {
      "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "updatedInterest": {
          "uuid": "string",
          "name": "string",
          "description": "string",
          "group": "string",
          "followers": []
        }
      }
      

Remove Interest

Endpoint: /interests/remove/interest/:uuid

Method: DELETE

Description: Removes an interest from the system.

Path Parameters:

Parameter Type Required Description
uuid string Required Interest's UUID

Error Responses:

  • 401 Unauthorized
    • Response Body:
      {
        "error": "Invalid interest"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The interest {uuid} has been removed successfully"
      }
      

Fetch Interest

Endpoint: /interests/fetch/interest/:uuid

Method: GET

Description: Fetches an interest from the system.

Path Parameters:

Parameter Type Required Description
uuid string Required Interest's UUID

Error Responses:

  • 404 Not Found
    • Response Body:
      {
        "error": "Interest not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "interest": {
          "uuid": "string",
          "name": "string",
          "description": "string",
          "group": "string",
          "followers": []
        }
      }
      

Fetch Interests

Endpoint: /interests/fetch/interests

Method: GET

Description: Fetches all interests from the system.

Error Responses:

  • 404 Not Found
    • Response Body:
      {
        "error": "Interests not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "interests": [
          {
            "uuid": "string",
            "name": "string",
            "description": "string",
            "group": "string",
            "followers": []
          }
        ]
      }
      

Add Follower

Endpoint: /interests/add/follower

Method: POST

Description: Adds a follower to an interest.

Request Body:

Parameter Type Required Description
interestUUID string Required Interest's UUID
userUUID string Required User's UUID

Error Responses:

  • 400 Bad Request
    • Response Body:
      {
        "error": [
          {
            "msg": "Interest uuid is required",
            "param": "interestUUID",
            "location": "body"
          },
          {
            "msg": "User uuid is required",
            "param": "userUUID",
            "location": "body"
          }
        ]
      }
      
  • 404 Not Found
    • Response Body:
      {
        "error": "Interest not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The follower {userUUID} has been added to Interest {interestUUID} successfully"
      }
      

Remove Follower

Endpoint: /interests/remove/follower

Method: DELETE

Description: Removes a follower from an interest.

Request Body:

Parameter Type Required Description
interestUUID string Required Interest's UUID
userUUID string Required User's UUID

Error Responses:

  • 400 Bad Request
    • Response Body:
      {
        "error": [
          {
            "msg": "Interest uuid is required",
            "param": "interestUUID",
            "location": "body"
          },
          {
            "msg": "User uuid is required",
            "param": "userUUID",
            "location": "body"
          }
        ]
      }
      
  • 404 Not Found
    • Response Body:
      {
        "error": "Interest not found"
      }
      
  • 500 Internal Server Error
    • Response Body:
      {
        "error": "Internal Server Error"
      }
      

Success Response:

  • 200 OK
    • Response Body:
      {
        "message": "The follower {userUUID} has been removed from Interest {interestUUID} successfully"
      }