Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

TusharYaar/appointy-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Details

Made for appointy task
Made by Tushar S Agrawal
Reg no: 19BCE0559
Submitted on 9th October, 2021

Installation

clone the repo

make sure you are in root folder

run go get go.mongodb.org/mongo-driver/mongo to install mongo drivers

use go run main.go to start the server

For Testing

cd testing

go test

Routes

  • POST /user adds new user
  • GET /user/<user_id> returns details of specified user
  • POST /post adds new post
  • GET /post/<post_id> returns details of specified post
  • GET /post/user/<user_id> returns all post by specific user
  • GET /post/user/<user_id>?page=<page_no>&limit=<limit> returns all post by specific user with pagination

Testing

cd testing

  • /user - 5 tests cases
  • /user/<user_id> - 4 tests cases
  • /post - 5 tests cases
  • /post/<post_id> - 4 tests cases
  • /post/user/<user_id>- 5 tests cases

About Database

  1. Uses mongodb Atlas, and connects via url.
  2. uses a temporary user

About Data

4 accounts are available now.

id: 6161447d56188e12db944c80
email: tusharsagrawal6@gmail.com
name: Tushar S Agrawal
number of posts: 5


id: 6160b6d57da33296d38ef6a6
email: ema23il2@gmail.com
name: sdcvsdc
number of posts: 4

id: 6160baddd5efcdffb10eab63
email: emal2@gmail.com
name: sdvsdvc
number of posts: 1

id: 61619a2d51169d1757ad2021
name: "test"
email: "test@test.com"
number of posts: 1

Folder Structure

|- root
    |-connection
        |-connection.go
    |-handlers                      //contains route handlers
        |-create_post.go            // POST /post
        |-create_user.go            // POST /user
        |-get_post.go               // GET /post/<post_id>
        |-get_posts_by_user.go      // GET /posts/user/<user_id>
        |-get_user.go               // GET /user/<user_id>
    |-models                        //contains models for user and post
        |-post.go                   //post struct
        |-user.go                   //user struct
    |-testing                       //contains unit test for handlers
        |-create_post_test.go       //POST /post
        |-create_user_test.go       // POST /user
        |-get_post_test.go          // GET /post/<post_id>
        |get_post_by_user_test.go   //GET /posts/user/<user_id>
        |get_user_test.go           // GET /user/<user_id>
    |-go.mod
    |-go.sum
    |-main.go                       //Main Fnction
    |-README.md

About

Submission for appointy internship task for technical group.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages