Giter VIP home page Giter VIP logo

social-media-api's Introduction

Social Media API

This is a backend API for a social media platform built with Node.js, Express.js, and MongoDB. The API allows users to sign up, log in, create posts, like posts, follow and unfollow other users, and get a list of posts from users they are following.

Installation

  1. Clone the repository: https://github.com/Ashu-14-oct/social-media-api.git
  2. Install dependencies: npm install
  3. Create a .env file in the root directory and add your secret key
  4. Start the server: npm start

Usage

The API has the following endpoints:

Authentication

POST /sign-up

Sign up a new user with a name, email, and password. Returns a JWT token.

POST /sign-in

Log in an existing user with an email and password. Returns a JWT token.

Posts

POST /create-post

Create a new post with a title and content.

GET /get-post/:id

Get a single post by ID.

Follow

POST /follow/:id

Follow a user by ID.

POST unfollow/:id

Unfollow a user by ID.

Users

GET /user/:id/posts

Get a list of posts by a user.

GET /user/:id/following

Get a list of users that a user is following.

GET /user/:id/followers

Get a list of users that follow a user.

Example requests

Sign up

POST /sign-up { "name": "John Doe", "email": "[email protected]", "password": "password" }

Log in

POST /sign-in { "email": "[email protected]", "password": "password" }

Create a post

POST /api/posts { "content": "Hello, world!" }

Follow a user

POST /follow/607f1d38f7ed310fd432dbaf

Unfollow a user

POST /unfollow/607f1d38f7ed310fd432dbaf

License

This project is licensed under the MIT License - see the LICENSE file for details.

social-media-api's People

Contributors

ashu-14-oct avatar

Stargazers

 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.