Git Product home page Git Product logo

ranjeetraj444 / idea-clan-assignment Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 446 KB

The Social Media API is a Node.js application developed to simulate basic functionalities of a social media platform. It allows users to register, authenticate, create posts, and retrieve user posts. The API utilizes Express.js for server setup, GraphQL for querying data, and follows an object-oriented approach for data modeling.

Home Page: https://idea-clan-assignment-atca.onrender.com

JavaScript 100.00%
cors expressjs graphql jasonwebtoken nodejs

idea-clan-assignment's Introduction

Social Media API

Overview

The Social Media API is a Node.js application developed to simulate basic functionalities of a social media platform. It allows users to register, authenticate, create posts, and retrieve user posts. The API utilizes Express.js for server setup, GraphQL for querying data, and follows an object-oriented approach for data modeling.

Use this templete for service

Send a POST request to query this endpoint

$ curl --request POST
--header 'content-type: application/json'
--url 'https://idea-clan-assignment-atca.onrender.com/graphql'
--data '{"query":"query { __typename }"}'

Features

  • User Registration and Authentication
  • Posting Content
  • Retrieving Posts
  • GraphQL Integration
  • Object-Oriented Design

To use in your local Stystem

Requirements

  • Node.js
  • npm (Node Package Manager)

Installation

  • Clone this repository to your local machine:

    git clone <"repository-url">
    
  • Navigate to the project directory:

    cd social-media-api
  • Install dependencies:

    npm install

Usage

  • Start the server:
    npm start
  • Access the GraphQL Playground at http://localhost:3000/graphql in your web browser.
  • Use the provided queries and mutations to interact with the API.

Queries and Mutations

  • Register a User:

    mutation {
    registerUser(username: "exampleUser", email: "[email protected]", password: "password") {
      id
      username
      email
    }
    }
  • Login a User:

    mutation {
    loginUser(email: "[email protected]", password: "password") {
      id
      username
      email
      token
    }
    }
  • Create a Post:

    mutation {
    createPost(userId: "<USER_ID>", content: "This is a new post.") {
      id
      userId
      content
     }
    }
  • Retrieve a User:

    query {
    getUser(id:"<USER_ID>"){
      id,
      username,
      email,
      }
      }
  • Retrieve a Post:

    query {
    getPost(id: "<POST_ID>") {
    id
    userId
    content
      }
      }
  • Retrieve User's Posts:

    query {
    getUserPosts(username: "<USER_ID>"){
      id,
      userId
      content
      }
    }

TechStack Used

  • Node.js
  • Express.js for server setup and middleware
  • GraphQL for API development
  • Apollo Server for handling GraphQL requests
  • MongoDB for database management system
  • Mongoose ODM to interact with the MongoDB database

idea-clan-assignment's People

Contributors

ranjeetraj444 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.