Skip to content

shashank-crypto/APIwithGO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instagram API using GO

Design and Develop an HTTP JSON API capable of the following operations,

  • Create an User
    • Should be a POST request
    • Use JSON request body
    • URL should be ‘/users'
  • Get a user using id
    • Should be a GET request
    • Id should be in the url parameter
    • URL should be ‘/users/’
  • Create a Post
    • Should be a POST request
    • Use JSON request body
    • URL should be ‘/posts'
  • Get a post using id
    • Should be a GET request
    • Id should be in the url parameter
    • URL should be ‘/posts/’
  • List all posts of a user
    • Should be a GET request
    • URL should be ‘/posts/users/'

JSON API created

controllers

  • getConnection handles connecting to the DB
  • createUser creats the user and pushing the user to DB
  • handleCreateUser handles the creating of the user and showing the Id as res
  • createPost creates the Post and push to the DB
  • handleCreatePost handles the createPost and shows the Id as res
  • getUser gets the user id and name from the DB and takes the :userId as param
  • getPost gets the post complete information saved in the DB and takes :postId as param
  • listPost lists all the posts created by the user and takes :userId as param

Two models

  • Users
  • Posts

MongoDB

  • instagram
    • posts
      • _id
      • caption
      • author
      • PostedTimeStamp
    • users
      • _id
      • name
      • email
      • password (hashed)

Testing the API endpoints and there result test report

On Postman Testing results

  1. getUser
  2. postPost
  3. createUser
  4. listUserPosts

Pagination has been used in the listPost and gives 2 posts for each page
Passwords are hashed before it is saved in the DB (using bcrypt)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages