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.
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 }"}'
- After visiting to the Url:-- https://idea-clan-assignment-atca.onrender.com/graphql
- User Registration and Authentication
- Posting Content
- Retrieving Posts
- GraphQL Integration
- Object-Oriented Design
- Node.js
- npm (Node Package Manager)
-
Clone this repository to your local machine:
git clone <"repository-url">
-
Navigate to the project directory:
cd social-media-api
-
Install dependencies:
npm install
- 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.
-
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 } }
- 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