Skip to content

joowoonk/textagram-be

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

73 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Textagram API Documentation

BaseURL: https://textagram-be.herokuapp.com/

A REST API using Node.js, Express, knex.js, and PostgresQL.
Authentication implemented using bcrypt and JSON web token.

Endpoints

Authentication

POST - Register a new user

Endpoint: /auth/register
Requires an object with an email, password and username:

{
  "email": "john@email.com",
  "password": "password",
  "username": "john"
}

When successful will return status code of 201 (CREATED), the new user object and a token (example):

{
  "User": {
    "id": 2,
    "username": "john",
    "email": "john@mail.com",
    "created_at": "2020-07-30T09:39:45.164Z",
    "fake_id": "acct45113",
    "location": null,
    "profile_picture": "https://static.wixstatic...",
    "about": "About yourself",
    "is_admin": false
  },
  "token": "eyJhbGc..."
}
{
  "User": {
    "id": 1,
    "username": "admin",
    "email": "admin@textagram.com",
    "created_at": "2020-07-24 10:10:29",
    "fake_id": "ADMINKANG", //
    "location": null,
    "profile_picture": "https://static.wixstat...",
    "about": "About yourself",
    "is_admin": true
  },
  "token": "eyJhbGc..."
}
POST - Login into an account

Endpoint: /auth/login
Requires an object with an email and password:

{
  "email": "john@mail.com",
  "password": "password"
}

When successful will return status code of 201 (CREATED), the new user object and a token (example):

{
  "user": {
    "id": 2,
    "username": "John",
    "email": "john@mail.com",
    "created_at": "2020-09-06T07:02:30.764Z",
    "fake_id": "acct0fe28",
    "location": "Berlin, Germany",
    "profile_picture": "https://static.wixstat...",
    "about": "About yourself",
    "is_admin": false
  },
  "token": "eyJhbG..."
}
{
  "user": {
    "id": 1,
    "username": "KANG",
    "email": "admin@textagram.com",
    "created_at": "2020-07-24 10:10:29",
    "fake_id": "ADMINKANG", //
    "location": null,
    "profile_picture": "https://static.wixstat...",
    "about": "About yourself",
    "is_admin": true
  },
  "token": "eyJhbGc..."
}

Users

GET - Get all users

Endpoint: /users/
No token or request body required.

When successful will return status code of 200 (OK) and an array of users.

[
  {
    "id": 1,
    "username": "KANG",
    "password": "$2a$10$XMCULNrp8qcFE4b5SmjxfOdOi4nJ9vaL94oTsEX9p1Qd8HmA.zdNa",
    "email": "admin@textagram.com",
    "created_at": "2020-09-19T20:51:24.150Z",
    "fake_id": "ADMINKANG",
    "location": "Los Angeles, CA",
    "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549136/textagram/jjlsiypxt95wsjpb7cxu.png",
    "about": "Welcome to my website! If you run into any bugs or issues send me a message to get it fixed. I will handle all of the technical details and making sure you have a smooth experience.",
    "is_admin": true
  },
  {
    "id": 2,
    "username": "John",
    "password": "$2a$10$/kJRwItSVmcfQ0tDL1vIW.vIX5YOr9oQs/WB.auplvvLxF5B4SfkW",
    "email": "john@mail.com",
    "created_at": "2020-09-19T20:51:57.894Z",
    "fake_id": "acct862b6",
    "location": "New York, NY",
    "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549341/textagram/f1xcdiwslh7hu50dipql.jpg",
    "about": "Would you like to recommend me great movies?",
    "is_admin": false
  }
]
GET - Get a single user by ID

Endpoint: /users/:id
No token or request body required.

When successful will return status code of 200 (OK) and the user in an object. The user by id endpoint includes the user's bio info, as well as their array of posts, up votes, down votes, comments,favorites, and followers.

{
  "user": {
    "id": 2,
    "username": "John",
    "email": "john@mail.com",
    "created_at": "2020-09-19T20:51:57.894Z",
    "fake_id": "acct862b6",
    "location": "New York, NY",
    "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549341/textagram/f1xcdiwslh7hu50dipql.jpg",
    "about": "Would you like to recommend me great movies?",
    "is_admin": false,
    "posts": [
      {
        "id": 3,
        "title": "One of best quote from Rush",
        "context": [
          "A wise man can learn more from his enemies than a fool from his friends.",
          "      โ€“Niki Lauda"
        ],
        "created_at": "2020-09-19T20:52:16.194Z",
        "hashtags": ["#movie", "#Rush", "#inspirational"],
        "user_id": 2,
        "feeling": "๐Ÿ˜ƒ awesome",
        "votes": 0,
        "comments": []
      },
      {
        "id": 2,
        "title": "One of best quote from Forrest Gump",
        "context": [
          "My mama always said, โ€˜Life was like a box of chocolates. You never know what youโ€™re gonna get.'",
          "         -Forrest Gump"
        ],
        "created_at": "2020-09-19T20:52:16.194Z",
        "hashtags": ["#bestMovie", "#forrest", "#gump", "#life"],
        "user_id": 2,
        "feeling": "๐Ÿ˜‡ optimistic",
        "votes": 0,
        "comments": [
          {
            "id": 8,
            "comment": ["Forest Gump is such a best movie in our life time"],
            "created_at": "2020-09-19T20:52:52.928Z",
            "user_id": 3,
            "fake_id": "acctdd1d3",
            "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549277/textagram/b2plpajntmyovuknnkcp.jpg"
          }
        ]
      },
      {
        "id": 18,
        "title": "Gratitude (an excerpt from my writing)",
        "context": [
          "Gratitude",
          "",
          "      Fight is what gets you up each morning. It is what pushes you and keeps you grounded when you take your next step. The pain and struggle that you endure on a daily basis makes you appreciate the good moments of life. Iโ€™ve learned that the reward you receive is when you start reaching that never-ending goal of greatness. Being grateful for these moments can propel you to that next step. I understand that the road is not always easy but once you come to that realization that you can take those next steps, then anything is possible. Keep faith and expect the best.",
          "      ",
          "      \"As we express our gratitude, we must never forget that the highest appreciation is not to utter words but to live by them.\" John F. Kennedy. Embrace this. There are too many people in this world who take things for granted, including themselves. In the bigger picture, you will never get satisfaction from those great moments if you donโ€™t appreciate even the smallest moments in your life. If you receive a compliment, embrace those words like John F Kennedy stated. Why would someone give you a compliment that they thought out, and not wanted you to feel good about it? They mean it and want you to receive their reward.",
          "      This Post was from r/inspiration",
          "      [https://www.reddit.com/r/inspiration/comments/inbv68/gratitude_an_excerpt_from_my_writing/]"
        ],
        "created_at": "2020-09-19T20:52:35.170Z",
        "hashtags": ["#reddit", "#inspiration"],
        "user_id": 2,
        "feeling": "๐Ÿ˜Š thankful",
        "votes": 2,
        "comments": []
      }
    ],
    "bookmarks": [],
    "upVotes": [],
    "downVotes": [],
    "following": [],
    "followers": []
  },
  "post": [
    {
      "id": 3,
      "title": "One of best quote from Rush",
      "context": [
        "A wise man can learn more from his enemies than a fool from his friends.",
        "      โ€“Niki Lauda"
      ],
      "created_at": "2020-09-19T20:52:16.194Z",
      "hashtags": ["#movie", "#Rush", "#inspirational"],
      "user_id": 2,
      "feeling": "๐Ÿ˜ƒ awesome",
      "votes": 0,
      "comments": []
    },
    {
      "id": 2,
      "title": "One of best quote from Forrest Gump",
      "context": [
        "My mama always said, โ€˜Life was like a box of chocolates. You never know what youโ€™re gonna get.'",
        "         -Forrest Gump"
      ],
      "created_at": "2020-09-19T20:52:16.194Z",
      "hashtags": ["#bestMovie", "#forrest", "#gump", "#life"],
      "user_id": 2,
      "feeling": "๐Ÿ˜‡ optimistic",
      "votes": 0,
      "comments": [
        {
          "id": 8,
          "comment": ["Forest Gump is such a best movie in our life time"],
          "created_at": "2020-09-19T20:52:52.928Z",
          "user_id": 3,
          "fake_id": "acctdd1d3",
          "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549277/textagram/b2plpajntmyovuknnkcp.jpg"
        }
      ]
    },
    {
      "id": 18,
      "title": "Gratitude (an excerpt from my writing)",
      "context": [
        "Gratitude",
        "",
        "      Fight is what gets you up each morning. It is what pushes you and keeps you grounded when you take your next step. The pain and struggle that you endure on a daily basis makes you appreciate the good moments of life. Iโ€™ve learned that the reward you receive is when you start reaching that never-ending goal of greatness. Being grateful for these moments can propel you to that next step. I understand that the road is not always easy but once you come to that realization that you can take those next steps, then anything is possible. Keep faith and expect the best.",
        "      ",
        "      \"As we express our gratitude, we must never forget that the highest appreciation is not to utter words but to live by them.\" John F. Kennedy. Embrace this. There are too many people in this world who take things for granted, including themselves. In the bigger picture, you will never get satisfaction from those great moments if you donโ€™t appreciate even the smallest moments in your life. If you receive a compliment, embrace those words like John F Kennedy stated. Why would someone give you a compliment that they thought out, and not wanted you to feel good about it? They mean it and want you to receive their reward.",
        "      This Post was from r/inspiration",
        "      [https://www.reddit.com/r/inspiration/comments/inbv68/gratitude_an_excerpt_from_my_writing/]"
      ],
      "created_at": "2020-09-19T20:52:35.170Z",
      "hashtags": ["#reddit", "#inspiration"],
      "user_id": 2,
      "feeling": "๐Ÿ˜Š thankful",
      "votes": 2,
      "comments": []
    }
  ]
}
PUT - Update an existent user

Endpoint: /users/:id
Authorization token required in headers. The user is authorized to update their own bio. Admin has accessibility to update other accounts' information as well. Requires a request body with the updated changes. Please see Data model portion of this documentation for required fields. Here is an example:

{
  "profile_picture": "https://res.cloudinary.com/...",
  "about": "Glad to meet you!",
  "location": "Los Angeles, CA"
}

When successful will return status code of 201 (CREATED), the updated user object (example):

{
  "editedProfile": {
    "id": 2,
    "username": "John",
    "email": "john@mail.com",
    "created_at": "2020-09-06T07:02:30.764Z",
    "fake_id": "acct0fe28",
    "location": "Los Angeles, CA",
    "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324054/textagram/x1wmrtzx4lskie9dx4gk.png",
    "about": "Glad to meet you!",
    "is_admin": false
  }
}

Posts

GET - Fetching all posts

Endpoint: /posts
No token or request body required.

When successful will return status code of 200 (READ), the all posts (example):

{
  "posts": [
    {
      "id": 5,
      "title": "Life isn't easy",
      "context": [
        "Living a life isn't a easy process, but do we really get to live a life we want? We will really have to think about that. Is this life what you want? If you die tonight, would you say you lived a life that you wanted? What are the things you can fix today? or something you need to do. Long term problem isn't something you may not be able to escape but are you working on it at least little by little?, you will be able to fix them eventually. Start small. You will be able to overcome it in the end."
      ],
      "created_at": "2020-09-06T07:02:36.356Z",
      "user_id": 3,
      "feeling": "๐Ÿง motivated",
      "hashtags": ["#encouraging", "#life"],
      "fake_id": "acct5fbf4",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324171/textagram/qvgz8succ7lvqmh287nl.jpg",
      "is_admin": false,
      "votes": 0,
      "comments": 0
    },
    {
      "id": 4,
      "title": "One of best line I heard from Yoda!",
      "context": [
        "Do, or do not. There is no 'try' ",
        "      ",
        "      - Yoda"
      ],
      "created_at": "2020-09-06T07:02:36.356Z",
      "user_id": 3,
      "feeling": "๐Ÿ˜Œ chill",
      "hashtags": ["#StarWars", "#MayTheForceBeWithYou", "#Yoda"],
      "fake_id": "acct5fbf4",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324171/textagram/qvgz8succ7lvqmh287nl.jpg",
      "is_admin": false,
      "votes": 1,
      "comments": 3
    },
    {
      "id": 3,
      "title": "One of best quote from Rush",
      "context": [
        "A wise man can learn more from his enemies than a fool from his friends.",
        "      โ€“Niki Lauda"
      ],
      "created_at": "2020-09-06T07:02:36.356Z",
      "user_id": 2,
      "feeling": "๐Ÿคฉ amazing",
      "hashtags": ["#movie", "#Rush", "#inspirational"],
      "fake_id": "acct0fe28",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324054/textagram/x1wmrtzx4lskie9dx4gk.png",
      "is_admin": false,
      "votes": 1,
      "comments": 0
    },
    {
      "id": 2,
      "title": "One of best quote from Forrest Gump",
      "context": [
        "My mama always said, โ€˜Life was like a box of chocolates. You never know what youโ€™re gonna get.'",
        "         -Forrest Gump"
      ],
      "created_at": "2020-09-06T07:02:36.356Z",
      "user_id": 2,
      "feeling": "๐Ÿ˜ญ emotional",
      "hashtags": ["#bestMovie", "#forrest", "#gump", "#life"],
      "fake_id": "acct0fe28",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324054/textagram/x1wmrtzx4lskie9dx4gk.png",
      "is_admin": false,
      "votes": 2,
      "comments": 1
    },
    {
      "id": 1,
      "title": "One best quote regarding a honest friendship",
      "context": [
        "Bestfriend is not just a word. A best friend is someone who is there for you, no matter what. Thick or thin. I can label anyone as a friend. But a bestfriend..? That is something that needs to be earned. A bestfriend knows me sometimes more than I know myself. Bestfriends share tears and laughs. You can trust them with anything and everything. I have a bunch of friends, but only a few that I can count on completely"
      ],
      "created_at": "2020-09-06T07:02:36.356Z",
      "user_id": 1,
      "feeling": "๐Ÿ˜ƒ fat",
      "hashtags": ["#friendship", "#friends", "#bestFriend"],
      "fake_id": "ADMINKANG",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324311/textagram/fdbinbuqtbtls3lp8wsk.png",
      "is_admin": true,
      "votes": 1,
      "comments": 4
    }
  ]
}
GET - Fetching a single post by ID Endpoint: `/posts/:id`
No token or request body required.

When successful will return status code of 200 (OK) and the posts object. The posts by id endpoint includes the post details as well as the total of votes (up votes - down votes), and array of comments.

{
  "post": {
    "id": 1,
    "title": "One best quote regarding a honest friendship",
    "context": [
      "Bestfriend is not just a word. A best friend is someone who is there for you, no matter what. Thick or thin. I can label anyone as a friend. But a bestfriend..? That is something that needs to be earned. A bestfriend knows me sometimes more than I know myself. Bestfriends share tears and laughs. You can trust them with anything and everything. I have a bunch of friends, but only a few that I can count on completely"
    ],
    "created_at": "2020-09-06T07:02:36.356Z",
    "hashtags": ["#friendship", "#friends", "#bestFriend"],
    "feeling": "๐Ÿ˜ƒ fat",
    "fake_id": "ADMINKANG",
    "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324311/textagram/fdbinbuqtbtls3lp8wsk.png",
    "is_admin": true,
    "user_id": 1,
    "votes": {
      "votes": 1,
      "upVoted": [
        {
          "user_id": 25,
          "post_id": 1,
          "fake_id": "acct87314",
          "profile_picture": "https://static.wixstatic.com/media/4151a5_7706b6198d164a3e947f4548166228ad~mv2.png"
        }
      ],
      "downVoted": []
    },
    "comments": [
      {
        "id": 2,
        "comment": [
          "Having three real friends in life is equivalent to having a successful life"
        ],
        "created_at": "2020-09-06T07:02:50.828Z",
        "user_id": 3,
        "fake_id": "acct5fbf4",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324171/textagram/qvgz8succ7lvqmh287nl.jpg"
      },
      {
        "id": 8,
        "comment": ["This is great!"],
        "created_at": "2020-09-13T08:22:34.068Z",
        "user_id": 32,
        "fake_id": "acctfed4a",
        "profile_picture": "https://static.wixstatic.com/media/4151a5_7706b6198d164a3e947f4548166228ad~mv2.png"
      },
      {
        "id": 11,
        "comment": ["Thank you guys!", "", "I really appreicated!", ""],
        "created_at": "2020-09-13T08:45:16.589Z",
        "user_id": 1,
        "fake_id": "ADMINKANG",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324311/textagram/fdbinbuqtbtls3lp8wsk.png"
      },
      {
        "id": 15,
        "comment": ["@acct5fbf4 I agree 100%"],
        "created_at": "2020-09-14T04:58:59.055Z",
        "user_id": 1,
        "fake_id": "ADMINKANG",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600324311/textagram/fdbinbuqtbtls3lp8wsk.png"
      }
    ]
  }
}
PUT - Edit post by ID Endpoint: `/posts/:id`
Authorization token required in headers. The user is authorized to update their own post. Admin has accessibility to update other accounts' posts as well.

Requires a request body with the updated changes. Please see Data model portion of this documentation for required fields. Here is an example:

{
  "title": "UPDATED:A Famous Quote from back to the future",
  "hashtags": ["#quote", "#movie"]
}
{
  "id": 33,
  "title": "UPDATED:A Famous Quote from back to the future",
  "context": [
    "โ€œYour future is whatever you make it, so make it a good one.โ€ - Doc"
  ],
  "created_at": "2020-09-20T22:18:57.457Z",
  "hashtags": ["#quote", "#movie"],
  "feeling": "๐Ÿ˜‡ inspired",
  "fake_id": "acctfac9e",
  "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600640375/textagram/im1p8id2qeu9afrfkkfv.jpg",
  "is_admin": false,
  "user_id": 17,
  "votes": {
    "votes": 2,
    "upVoted": [
      {
        "user_id": 17,
        "post_id": 33,
        "fake_id": "acctfac9e",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600640375/textagram/im1p8id2qeu9afrfkkfv.jpg"
      },
      {
        "user_id": 18,
        "post_id": 33,
        "fake_id": "acctbd60a",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600664556/textagram/g246nirqugqljx9sx4no.jpg"
      }
    ],
    "downVoted": []
  }
}
GET - Search posts by titles Endpoint: `/posts/search/:title`

Requires a request body using params that matches a key word to find posts by title. As an example, a user uses keyword on the place of title https://textagram-be.herokuapp.com/api/posts/search/'famous' famouse will triger search and look for posts that has title of that key words.

{
  "posts": [
    {
      "id": 33,
      "title": "UPDATED:A Famous Quote from back to the future",
      "context": [
        "โ€œYour future is whatever you make it, so make it a good one.โ€ - Doc"
      ],
      "hashtags": ["#quote", "#movie"],
      "created_at": "2020-09-20T22:18:57.457Z",
      "feeling": "๐Ÿ˜‡ inspired",
      "fake_id": "acctfac9e",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600640375/textagram/im1p8id2qeu9afrfkkfv.jpg",
      "is_admin": false,
      "votes": 3,
      "comments": 0
    }
  ]
}
POST - Add a new post Endpoint: `/posts`

Authorization token required in headers. This is how the user's id is assigned to their post. Requires a request body with the post info. Please see Data model portion of this documentation for required fields. Here is an example:

{
  "title": "Just because you are in a bad situation",
  "hashtags": "",
  "context": "Doesn't mean you will stuck in a bad place forever, I hope you find things what you can control. Doesn't matter if it's small but keep on working on small things. Once you know how to finish small thing well, bigger things will come to you when you are ready."
}

When successful will return status code of 201 (CREATED), the new post object that are joint with other tables:

{
  "newPost": {
    "id": 37,
    "title": "Just because you are in a bad situation",
    "context": [
      "Doesn't mean you will stuck in a bad place forever, I hope you find things what you can control. Doesn't matter if it's small but keep on working on small things. Once you know how to finish small thing well, bigger things will come to you when you are ready."
    ],
    "created_at": "2020-09-24T05:40:20.453Z",
    "hashtags": [],
    "feeling": null,
    "fake_id": "accta1e96",
    "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600566435/textagram/oe7irlf84m4wbmaofboc.jpg",
    "is_admin": false,
    "user_id": 16,
    "votes": {
      "votes": 0,
      "upVoted": [],
      "downVoted": []
    }
  }
}
DELETE - Delete Post by ID Endpoint: `/posts/:id`

Authorization token required in headers. Only the user is authorized to delete their own posts. No request body required. Admin has accessibility to delete other accounts' posts as well.

When successful will return status code of 200 (OK) and a success message:

{
  "message": "Your post is gone."
}
PUT - Update Post by ID Endpoint: `/posts/:id`

Authorization token required in headers. Only the user is authorized to delete their own posts. No request body required. Admin has accessibility to update other accounts' posts as well.

Please see Data model portion of this documentation for required fields. Here is an example:

{
  "title": "UPDATED:A Famous Quote from back to the future",
  "hashtags": ["#quote", "#movie"]
}

When successful will return status code of 201 (CREATED) and with the post that's been updated:

{
  "id": 33,
  "title": "UPDATED:A Famous Quote from back to the future",
  "context": [
    "โ€œYour future is whatever you make it, so make it a good one.โ€ - Doc"
  ],
  "created_at": "2020-09-20T22:18:57.457Z",
  "hashtags": ["#quote", "#movie"],
  "feeling": "๐Ÿ˜‡ inspired",
  "fake_id": "acctfac9e",
  "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600640375/textagram/im1p8id2qeu9afrfkkfv.jpg",
  "is_admin": false,
  "user_id": 17,
  "votes": {
    "votes": 3,
    "upVoted": [
      {
        "user_id": 17,
        "post_id": 33,
        "fake_id": "acctfac9e",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600640375/textagram/im1p8id2qeu9afrfkkfv.jpg"
      },
      {
        "user_id": 18,
        "post_id": 33,
        "fake_id": "acctbd60a",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600664556/textagram/g246nirqugqljx9sx4no.jpg"
      },
      {
        "user_id": 1,
        "post_id": 33,
        "fake_id": "ADMINKANG",
        "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549136/textagram/jjlsiypxt95wsjpb7cxu.png"
      }
    ],
    "downVoted": []
  }
}
POST - Bookmark Post by ID Endpoint: `/posts/:id/bookmark`

Authorization token required in headers. Only the user is authorized to bookmark others' posts. No request body required.

As for example, inserted id 21 on :id area.

When successful will return status code of 200 (OK) and of every post that the user bookmarked so far including post's id by 21:

{
  "post": [
    ...post,
    {
      "id": 21,
      "title": "Hello From The Admin!",
      "context": [
        "Welcome to my website! Start coding since Feb. 2020! If you run into any bugs or issues send me a message to get it fixed. I will handle all the technical details and making sure you have a smooth experience. - 9/19/2020"
      ],
      "user_id": 1,
      "fake_id": "ADMINKANG",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549136/textagram/jjlsiypxt95wsjpb7cxu.png",
      "bookmarks": "6",
      "comments": 0
    },
    {
      "id": 1,
      "title": "One best quote regarding a honest friendship",
      "context": [
        "Bestfriend is not just a word. A best friend is someone who is there for you, no matter what. Thick or thin. I can label anyone as a friend. But a bestfriend..? That is something that needs to be earned. A bestfriend knows me sometimes more than I know myself. Bestfriends share tears and laughs. You can trust them with anything and everything. I have a bunch of friends, but only a few that I can count on completely"
      ],
      "user_id": 1,
      "fake_id": "ADMINKANG",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549136/textagram/jjlsiypxt95wsjpb7cxu.png",
      "bookmarks": "1",
      "comments": 2
    }
  ]
}
DELETE - Unbookmark Post by ID Endpoint: `/posts/:id/unbookmark`

Authorization token required in headers. Only the user is authorized to delete their own posts. No request body required.

When successful will return status code of 200 (OK) and a success message:

{
  "message": "The bookmark got canceled"
}
POST - Up Vote Post by ID Endpoint: `/posts/:id/upvote`

Authorization token required in headers. Only the user is authorized to up vote others' posts. No request body required.

As for example, inserted id 21 on :id area.

When successful will return status code of 201 (CREATE) and of every post that the user up votes on other posts including post's id by 21:

{
  "post": [
    ...posts,
    {
      "id": 21,
      "title": "Hello From The Admin!",
      "context": [
        "Welcome to my website! Start coding since Feb. 2020! If you run into any bugs or issues send me a message to get it fixed. I will handle all the technical details and making sure you have a smooth experience. - 9/19/2020"
      ],
      "user_id": 1,
      "fake_id": "ADMINKANG",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549136/textagram/jjlsiypxt95wsjpb7cxu.png",
      "votes": 4
    }
  ]
}
DELETE - Canceling Up Vote Post by ID Endpoint: `/posts/:id/removeupvote`

Authorization token required in headers. Only the user is authorized to cancel up vote others' posts. No request body required.

When successful will return status code of 200 (OK) and a success message:

{
  "message": "The up vote got canceled"
}
POST - Down Vote Post by ID Endpoint: `/posts/:id/upvote`

Authorization token required in headers. Only the user is authorized to up vote others' posts. No request body required.

As for example, inserted id 21 on :id area.

When successful will return status code of 201 (CREATE) and of every post that the user down votes on other posts including post's id by 21:

{
  "post": [
    ...posts,
    {
      "id": 21,
      "title": "Hello From The Admin!",
      "context": [
        "Welcome to my website! Start coding since Feb. 2020! If you run into any bugs or issues send me a message to get it fixed. I will handle all the technical details and making sure you have a smooth experience. - 9/19/2020"
      ],
      "user_id": 1,
      "fake_id": "ADMINKANG",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549136/textagram/jjlsiypxt95wsjpb7cxu.png",
      "votes": 3
    }
  ]
}
DELETE - Canceling Down Vote Post by ID Endpoint: `/posts/:id/removedownvote`

Authorization token required in headers. Only the user is authorized to cancel up vote others' posts. No request body required.

When successful will return status code of 200 (OK) and a success message:

{
  "message": "The down vote got canceled"
}

Comments

GET - Get Comment by ID Endpoint: `/comments/:id`

No token or request body required.

When successful will return status code of 200 (OK) and the comment objectt. The comment by id endpoint includes the comment details

{
  "comment": {
    "id": 6,
    "comment": ["first comments! Ooh hoo!"],
    "created_at": "2020-09-19T20:52:52.928Z",
    "post_id": 1,
    "user_id": 2
  }
}
POST - Add Comment by Post ID Endpoint: `/comments/:id`

Authorization token required in headers. Only the user is authorized to add a comment to a post by its post id.

When successful will return status code of 201 (CREATE) and comment object:

{
  "newComment": {
    "id": 24,
    "comment": ["Thank you for the post!"],
    "created_at": "2020-09-25T22:54:04.403Z",
    "post_id": 2,
    "user_id": 1
  }
}
GET - Get Comments by Post ID Endpoint: `/comments/post/:id`

No token or request body required.

When successful will return status code of 200 (OK) and the comment objects. The comment by post id endpoint including the comments' details

{
  "comments": [
    {
      "id": 6,
      "comment": ["first comments! Ooh hoo!"],
      "created_at": "2020-09-19T20:52:52.928Z",
      "user_id": 2,
      "fake_id": "acct862b6",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549341/textagram/f1xcdiwslh7hu50dipql.jpg"
    },
    {
      "id": 7,
      "comment": [
        "Having three real friends in life is equivalent to having a successful life"
      ],
      "created_at": "2020-09-19T20:52:52.928Z",
      "user_id": 3,
      "fake_id": "acctdd1d3",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549277/textagram/b2plpajntmyovuknnkcp.jpg"
    }
  ]
}
GET - Get Comments by User ID Endpoint: `/comments/user/:id`

No token or request body required.

When successful will return status code of 200 (OK) and the comment objects. The comments by user id endpoint including the comments' details

{
  "comments": [
    {
      "id": 6,
      "comment": ["first comments! Ooh hoo!"],
      "created_at": "2020-09-19T20:52:52.928Z",
      "post_id": 1,
      "user_id": 2
    },
    {
      "id": 9,
      "comment": ["May the force be with you!"],
      "created_at": "2020-09-19T20:52:52.928Z",
      "post_id": 4,
      "user_id": 2
    }
  ]
}
PUT - Edit comment by ID Endpoint: `/comments/:id`
Authorization token required in headers. The user is authorized to update their own post. Admin has accessibility to update other accounts' posts as well.

Requires a request body with the updated changes. Please see Data model portion of this documentation for required fields. Here is an example:

{
  "comment": ["Thank you for the post!"]
}

When successful will return status code of 201 (CREATED), the updated comment object (example):

{ "message": "comment now updated" }
DELETE - Delete Comment by ID Endpoint: `/comments/:id`

Authorization token required in headers. Only the user is authorized to delete their own comments. No request body required. Admin has accessibility to delete other accounts' comments as well.

When successful will return status code of 200 (OK) and a success message:

{
  "message": "Your comment's successfully deleted."
}

Follow

POST - Follow by USER ID Endpoint: `/followers/:id` Authorization token required in headers. Only the user is authorized to follow other users.

No token or request body required.

When successful will return status code of 201 (CREATE) and the user's followings in objects:

{
  "followered": [
    {
      "created_at": "2020-09-19T21:02:05.266Z",
      "id": 3,
      "fake_id": "acctdd1d3",
      "email": "david@mail.com",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549277/textagram/b2plpajntmyovuknnkcp.jpg",
      "location": "Cedar Rapids, Iowa"
    },
    {
      "created_at": "2020-09-24T23:34:56.861Z",
      "id": 16,
      "fake_id": "accta1e96",
      "email": "test9@mail.com",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600566435/textagram/oe7irlf84m4wbmaofboc.jpg",
      "location": "Los Angeles, CA"
    },
    {
      "created_at": "2020-09-19T21:04:44.135Z",
      "id": 4,
      "fake_id": "acct82883",
      "email": "jwkk@mail.com",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600549257/textagram/ndai4ovdwtcqbau20i2o.png",
      "location": "San Jose, CA"
    },
    {
      "created_at": "2020-09-26T00:39:19.696Z",
      "id": 5,
      "fake_id": "acct1a7ee",
      "email": "test1@mail.com",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600559571/textagram/jiabvdecyta6ie6h6fd5.png",
      "location": "Los Angeles, CA"
    },
    {
      "created_at": "2020-09-24T23:34:42.491Z",
      "id": 17,
      "fake_id": "acctfac9e",
      "email": "test10@mail.com",
      "profile_picture": "https://res.cloudinary.com/dujr5xene/image/upload/v1600640375/textagram/im1p8id2qeu9afrfkkfv.jpg",
      "location": "Hill Valley, CA"
    }
  ]
}
DELETE - Unfollow a user by other User ID Endpoint: `/followers/:id/`

Authorization token required in headers. Only the user is authorized to unfollow others. No request body required.

When successful will return status code of 200 (OK) and a success message:

message: "you've unfollowed this user"

About

2nd side-project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published