Coder Social home page Coder Social logo

instagram_backend's Introduction

Instagram Backend API

  • GOLANG APIs to handle USER and POST creation
  • These APIs only use go standard packages
  • MongoDB is used for storage

Prerequisites

  • MongoDB connection string / URI (Local or Remote)
  • GOLANG

Setup

  • Extract the repo into a folder, I'll be calling this Repo
  • Add this directory to GOPATH environment variable (Follow this for help)
  • Open the terminal of your choice and navigate to Repo/src/insta_backend
  • Run the below snippet to download the dependencies
 go mod download
  • Make sure you have the following environment variables setup:
MONGO_URI = <mongoDB connection string> // example: mongodb+srv://<user_name>:<password>@cluster0.spv7l.mongodb.net/Cluster0
MONGO_DBNAME = <name of the mongoDB database> //example: MONGO_DBNAME = "MyDB"
ENCRYPT_KEY = <32 BIT LONG ENCRYPTION KEY> //example: ENCRYPT_KEY = "thisis32bitlongpassphraseimusing"
PORT = <the port where the server will run>// example: PORT = :3000
  • Run the following snippet to start the server at the PORT
go run main.go

Usage

There are 5 endpoints relating to users and posts

GET /users/:id

This endpoint returns user object with the following structure:

id       //mongoObjectId
name     //string
email    //string
password //string

GET /posts/:id

This endpoint returns post object with the following structure:

id        //mongoObjectId
userId    //mongoObjectId
caption   //string
imageUrl  //string
postTime  //ISOSTRING

GET /posts/users/:id

This endpoint returns an array of post objects with the following structures:

id        //mongoObjectId
userId    //mongoObjectId
caption   //string
imageUrl  //string
postTime  //ISOSTRING

POST /users/

This endpoint returns objectId to of the user created, the request body should contain:

name     //string
email    //string
password //string

POST /posts/

This endpoint returns objectId to of the post created, the request body should contain:

userId    //mongoObjectId
caption   //string
imageUrl  //string
postTime  //ISOSTRING

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

instagram_backend's People

Contributors

dark0017 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.