Skip to content

This is a backend server application for a basic social media platform built with Node.js, Express, MongoDB, and GraphQL.

Notifications You must be signed in to change notification settings

shivamkumar24/idea-clan-social-media

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Social Media API

This is a backend server application for a basic social media platform built with Node.js, Express, MongoDB, and GraphQL.

Table of Contents

  1. Introduction
  2. Features
  3. Setup
  4. Endpoints
  5. GraphQL
  6. Authentication
  7. Dependencies
  8. License

Introduction

The Social Media API provides basic functionalities for user registration, authentication, posting content, following/unfollowing users, and retrieving posts. It is built using Node.js and Express framework, with MongoDB as the database. GraphQL is integrated for querying user profiles and posts.

Features

  • User registration and authentication
  • Posting content (text-based)
  • Following and unfollowing other users
  • Retrieving user posts and following users' posts
  • GraphQL endpoint for querying user profiles and posts

Setup

  1. Clone the repository: git clone <repository-url>

  2. Install dependencies: npm install

  3. Set up environment variables by creating a .env file and defining the following variables:

    • PORT=3000
    • MONGODB_URI=
    • JWT_SECRET=
  4. Start the server: npm start

Endpoints

User Endpoints

  • POST /register: Register a new user
  • POST /login: Login an existing user
  • GET /allusers: Get all users
  • GET /user/posts/:userId: Get posts for a specific user by userID
  • GET /following/posts/:userId: Get posts including those posted by users the current user is following
  • POST /follow: Follow a user
  • POST /unfollow: Unfollow a user

Post Endpoints

  • POST /post: Create a new post

GraphQL

The GraphQL endpoint is available at /graphql. You can use GraphiQL to explore the schema and execute queries.

Authentication

Authentication is implemented using JSON Web Tokens (JWT). When a user registers or logs in, a JWT token is generated and sent back to the client. This token should be included in the authorization header for protected routes.

Dependencies

  • express
  • mongoose
  • bcryptjs
  • jsonwebtoken
  • express-graphql (for GraphQL endpoint)
  • dotenv (for environment variables)
  • cors

Releases

No releases published

Packages

No packages published