Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

List of Backend Routes #62

Open
18 of 26 tasks
daniel-d-truong opened this issue May 20, 2020 · 1 comment
Open
18 of 26 tasks

List of Backend Routes #62

daniel-d-truong opened this issue May 20, 2020 · 1 comment
Assignees

Comments

@daniel-d-truong
Copy link
Collaborator

daniel-d-truong commented May 20, 2020

Make sure that every route includes the user UUID in the header

/api/post

  • GET (retrieves contents of a post)
  • POST (uploads a post to the backend)
  • PUT (updates property of a post)
  • DELETE (deletes a post)

/api/post/follow

  • POST (either adds or removes user from post's following list)
Request: postUUID
Response:
  Success: "Added user as a follower" or "Removed user as a follower"
  Failure: json object with the following: 
    {
      status: Number,
      error: String
    }

/api/user

  • GET (gets user data)
Request - nothing needed
Response - JSON of the User Obj
  • POST (creates a user)
Request (Body):
  {
    name: String,
    email: String,
    uuid: String
  }

Response: 
  Success: 200 status - "Added user __" 
  Failure: json object with the following: 
    {
      status: Number,
      error: String
    }
  • PUT (updates properties of a user)
Request (Body) - (each key/value is optional)
  {
    name: String,
    email: String,
    studentCourse: String (courseId),
    instructorCourse: String (courseId),
    post: String (postId),
    comment: String (commentId),
    followedPost: String (postId),
    likedPost: String (postId), 
    rmLikedPost: String (postId),
    likedComment: String (postId),
    rmLikedComment: String (postId).
    icon: String (image url) 
  }

Response - "Updated user."
  • DELETE (delete a user from firebase)
Request - nothing needed
Response - "Removed user from the database" 

/api/user/:courseID

  • GET (gets user's type in a course)
Request - nothing needed
Response - JSON object 
// "type" field shows if user is in course, "error" field shows if user is NOT in course
  {
    type: "Instructor" or "Student",
    error: "Error Message" 
  } 
  • POST (adds user to a given course) --> still needs ability to add instructor
Request - Body
  {
    "type": "Instructor" or "Student"
  }

Response 
  Success - "Added user to course"
  Failure - JSON object 
  {
    status: Number,
    error: "String 
  }
  • PATCH (updates user's status in a course)

/api/course

  • GET (all courses to join)
Request - nothing needed
Response - JSON object 
{
  "courseId": {
    // course information
   }, 
  "courseId2": {
    // course information for cousreId2
  },
  ...
}

  • POST (creates a course)
  • PATCH (updates properties of a course)

/api/course/:courseID

  • GET (course information about given course, data given should differ based on whether user is a student or instructor)
  Request - courseUUID
  Response - JSON (down below is an example) 

  {
    "instructorList": [
        "user2"
    ],
    "name": "cse110",
    "postList": [
        {
            "author": "user1",
            "commentList": [
                "comment1"
            ],
            "content": "my code is broken",
            "course": "course1",
            "followingList": [
                "user1"
            ],
            "isAnnouncement": false,
            "isAnonymous": true,
            "isInstructor": false,
            "isPinned": false,
            "isPrivate": true,
            "isResolved": false,
            "score": 283,
            "tagList": [
                "tag1"
            ],
            "time": "05122020 14:34",
            "title": "i need help",
            "uuid": "post2"
        },
        {
            "author": "user1",
            "commentList": [
                "comment1"
            ],
            "content": "my code is broken",
            "course": "course1",
            "followingList": [
                "user1"
            ],
            "isAnnouncement": true,
            "isAnonymous": true,
            "isInstructor": false,
            "isPinned": true,
            "isPrivate": false,
            "isResolved": false,
            "score": 285,
            "tagList": [
                "tag1"
            ],
            "time": "05122020 14:33",
            "title": "i need help",
            "uuid": "post1"
        }
    ],
    "studentList": [
        "user1",
        "3hTIrNf7sGS0Ne5oYMPKJdu6U7J3"
    ],
    "tagList": [
        {
            "author": "user1",
            "commentList": [
                "comment1"
            ],
            "content": "my code is broken",
            "course": "course1",
            "followingList": [
                "user1"
            ],
            "isAnnouncement": true,
            "isAnonymous": true,
            "isInstructor": false,
            "isPinned": true,
            "isPrivate": false,
            "isResolved": false,
            "score": 285,
            "tagList": [
                "tag1"
            ],
            "time": "05122020 14:33",
            "title": "i need help",
            "uuid": "post1"
        },
        {
            "author": "user1",
            "commentList": [
                "comment1"
            ],
            "content": "my code is broken",
            "course": "course1",
            "followingList": [
                "user1"
            ],
            "isAnnouncement": false,
            "isAnonymous": true,
            "isInstructor": false,
            "isPinned": false,
            "isPrivate": true,
            "isResolved": false,
            "score": 283,
            "tagList": [
                "tag1"
            ],
            "time": "05122020 14:34",
            "title": "i need help",
            "uuid": "post2"
        }
    ],
    "term": "sp20",
    "uuid": "course1",
    "type": "instructor"
}
  • DELETE (deletes the given course)

/api/course/:courseId/invite

  • POST request that sends an email with the appropriate invite link for the given course
Request (Body):
  {
    email: String,
    type: Instructor (optional, defaults to Student if not provided)
  }
Response:
  Success: "Invite sent!"
  Failure: json object with the following: 
    {
      status: Number,
      error: String
    }

/api/comment/

  • GET request that gets all comments associated with a post (pass in post ID)
  • POST request that creates a comment (must pass in a post ID)
  • PATCH request that updates property of a comment
  • DELETE request that deletes a given comment

/api/tag/

  • GET request that gets all tags associated with a course
Request: courseUUID
Response: 
[
    "tag has been added",
    "new tag",
    "-M8deXQL9pCj2rjJpz5D",
    "-M8dhbVLhWKBwfkwgcH3"
]
  • POST request that creates a tag
Request (Body):
  {
    name: String,
    course: String (courseId)
  }

Response:
  Success: 200 status - "Added tag __" 
  Failure: json object with the following: 
    {
      status: Number,
      error: String
    }
  • PUT request that updates a tag
Request (Body): (each key/value is optional)
  {
    name: String,
    parentTag: String (postId),
    rnParentTag: String (postId),
    subTag: String (postId),
    rmSubTag: String (postId),
    post: String (postId),
    rmPost: String (postId)
  }

Response: "Updated tag"
  • DELETE request that deletes a tag
Request: tagUUID
Response:
  Success: 200 status - "removed tag __" 
  Failure: json object with the following: 
    {
      status: Number,
      error: String
    }
@daniel-d-truong
Copy link
Collaborator Author

for the GET request of /api/course, I think it'd be great if we can manipulate our data so that we also include what type of user they are in the given course (taking the logic of the GET for /api/user/:courseID and applying it here as well). That way, only one backend call will be needed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants