This api has been built according to the task assigned by Apponity.

Appointy_Task

This api has been built according to the task assigned by Apponity. All the tasks Provided have been completed
Link to the Document of the task

Please excuse my mistakes in formatting or in the way program is structured if there are any, As this was the first time I have worked with the language GO

List of Task:

  • Api call to add new user
  • Api call to retrieve user based on the user_id
  • Api call to add posts
  • Api call to retrieve post based on post_id
  • Api call to retrieve all posts made by a particular user
  • The Api should be made using GO
  • MongoDB should be used for the database
  • Only particular libraries and packages were allowed
  • Password should be stored safely, so that it cannot be reengineered
  • The API should be thread safe
  • There must be pagination at list end points
  • There should be unit tests for all functions

Methods

Security of Password

For the security and safety of the password I have added salting and Hashing before storing it in the database.

hashedPassword, _ := bcrypt.GenerateFromPassword([]byte(u.Password), 8)

The function bcrypt has been used for this functionality

Thread safety of the Api

For thread safety so that only one user can update the database at a time. The lock.Lock() function has been applied on all the functions that have the ability to alter the database. In case of functions that don't alter the database the lock.Lock() function has not been applied because that would unnecessarlily make the api slower.

Pagination

All the API calls return only one json object except the last API which returns a list of objects containing posts generated by a particular user. In this particualr API call pagination has been applied by limiting the number of posts returned to 10.

findOptions := options.Find()
findOptions.SetLimit(5)
findOptions.SetSkip(0)

This is the code used for it

output of API calls :



Output of Adding a user to the MongoDB database : image
As you can see the Password is not in plain text it is in a hashed form

Output of Retrieving the User based on the user_id : image

Output of Adding a Post to the MongoDB database : image

Output of Retrieving a post based on the post_id :

image

Output of Retrieving all the posts made by a particular user based on the user_id : image
Because of Pagination a maximum 10 posts can be retrieved this will improve the time for API call

Owner
I am a coding enthusiast who has been completely immersed in the world of Machine/Deep learning for the past year and a half.
null
Similar Resources

Golang-module-references - A reference for how to setup a Golang project with modules - Task Management + Math Examples

Golang Module Project The purpose of this project is to act as a reference for setting up future Golang projects using modules. This project has a mat

Jan 2, 2022

Executor - Fast exec task with go and less mem ops

executor fast exec task with go and less mem ops Why we need executor? Go with g

Dec 19, 2022

The library solves the task of recalculating the exchange order book

fastme (fast golang matching engine) library Design The library solves the task of recalculating the exchange order book. A classic matching engine co

Aug 10, 2022

An application dedicated to the trivial and boring task of meal planning 📅 and generating shoppings list 🛒.

An application dedicated to the trivial and boring task of meal planning 📅 and generating shoppings list 🛒.

An application dedicated to the trivial and boring task of meal planning 📅 and generating shoppings list 🛒.

Mar 1, 2022

Phalanx is a cloud-native full-text search and indexing server written in Go built on top of Bluge that provides endpoints through gRPC and traditional RESTful API.

Phalanx Phalanx is a cloud-native full-text search and indexing server written in Go built on top of Bluge that provides endpoints through gRPC and tr

Dec 25, 2022

Example blog built with Go and the Cosmic Headless CMS 🔥

Example blog built with Go and the Cosmic Headless CMS 🔥

Go + Cosmic This repo contains an example blog starter that is built with Go, and Cosmic. See live demo hosted on Heroku Prerequisites Go (I recommend

May 8, 2022

A reward-based pseudo-currency system built exclusively for IIT Kanpur campus junta.

IITK Coin IITK Coin is a reward-based pseudo-currency system for the IIT Kanpur campus junta. Detailed vision and regulation rules of this currency ar

Nov 29, 2022

Web app built with Go/Golang and Buffalo, deployed on Heroku, using Heroku Postgres

hundred-go-buffalo Background Read Go Read Buffalo Read Getting Started on Heroku with Go Recommended Tools PowerShell terminal Chocolatey Windows pac

Dec 18, 2021

GolangChatroom - Live chatrooms built with Golang, React, and TypeScript with Webpack Hot Reloading

GolangChatroom - Live chatrooms built with Golang, React, and TypeScript with Webpack Hot Reloading

Go Live Chatrooms An example project demonstrating websockets and authentication

Jan 3, 2022
A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Sep 27, 2022
Go library for generate serial numbers according to rules.

go-sn - Serial Number Generator Go library for generate serial numbers according to rules. This library is also useful for generating serial numbers i

Sep 8, 2022
Every grain of sand on Earth has its own ID.

SandID Every grain of sand on Earth has its own ID. Note that the algorithm used to generate the sandid.SandID mainly come from the UUID version 1. So

Dec 18, 2022
Help to release a project which especially has multiple git repositories

This project aims to help to release a project which especially has multiple git repositories. Installation Install it to a Kubernetes cluster. You ca

Dec 15, 2022
It is a basic todo app which has CRUD operation using Buffalo and golang

It is a basic todo app which has CRUD operation using Buffalo and golang

Nov 1, 2021
Developed Code for the Fulfillment of the technical task given by Appointy using Go

INSTAGRAM BACKEND API BY KUNAL KULKARNI Table of Contents About The Project Built With Getting Started Prerequisites Installation Usage License Contac

Oct 10, 2021
This is the task done for Appointy

Instagram-Backend-API This is the task done for Appointy Tasks Done here : Create an User Should be a POST request Use JSON request body UR

Oct 9, 2021
Appointy internship task
Appointy internship task

appointy_task_Krishna_Harchandani Appointy internship task Appointy_Krishna_Harchandani Appointy Internship Task Instagram Backend API Krishna Harchan

Oct 9, 2021
Implementation of the test task, chat in the goland language
Implementation of the test task, chat in the goland language

Implementation of the test task, chat in the goland language

Dec 5, 2021
Let's Go is task sharing app implemented in golang.

Let's Go - A sample GO app Overview Let's Go is an HTTP server. It has various apis to play with. It is a small app that can group users of a company

Dec 13, 2021