Project Rongtuli- A Social Media App
Backend API Documentation for Rongtuli Project.

FaceHook Server API Routes

This document provides a simple explanation of the FaceHook API, including how to install and run the server, and details about its various endpoints.


Getting Started

Step 1: Install Required Packages

Run the following command to install all necessary dependencies:

npm install

Step 2: Start the Server

To start the server with authentication enabled, use this command:

npm run dev

API Documentation


📁 Authentication (Auth)

1. User Registration

  • Purpose: Register a new user.
  • Endpoint:
    POST {{BASE_URL}}/auth/register
  • Request Body:
    {
      "email": "example@mail.com",
      "password": "password123",
      "firstName": "John",
      "lastName": "Doe"
    }

2. User Login

  • Purpose: Log in and get access tokens.
  • Endpoint:
    POST {{BASE_URL}}/auth/login
  • Request Body:
    {
      "email": "example@mail.com",
      "password": "password123"
    }
  • Response: Contains user details and authentication tokens.

3. Refresh Token

  • Purpose: Refresh expired access tokens using a refresh token.
  • Endpoint:
    POST {{BASE_URL}}/auth/refresh-token
  • Request Body:
    {
      "refreshToken": "your-refresh-token"
    }

📁 Posts

1. Get All Posts

  • Purpose: Retrieve all posts.
  • Endpoint:
    GET {{BASE_URL}}/posts
  • Authentication: Required.

2. Get Single Post

  • Purpose: Retrieve a single post by its ID.
  • Endpoint:
    GET {{BASE_URL}}/posts/{postId}
  • Authentication: Required.

3. Create Post

  • Purpose: Create a new post.
  • Endpoint:
    POST {{BASE_URL}}/posts
  • Request Body:
    {
      "postType": "text",
      "body": "This is my post content."
    }
  • Authentication: Required.

4. Update Post

  • Purpose: Edit an existing post.
  • Endpoint:
    PATCH {{BASE_URL}}/posts/{postId}
  • Request Body:
    {
      "content": "Updated content."
    }
  • Authentication: Required.

5. Delete Post

  • Purpose: Remove a post.
  • Endpoint:
    DELETE {{BASE_URL}}/posts/{postId}
  • Authentication: Required.

6. Like Post

  • Purpose: Like a post.
  • Endpoint:
    PATCH {{BASE_URL}}/posts/{postId}/like
  • Authentication: Required.

7. Comment on Post

  • Purpose: Add a comment to a post.
  • Endpoint:
    PATCH {{BASE_URL}}/posts/{postId}/comment
  • Request Body:
    {
      "comment": "This is my comment."
    }
  • Authentication: Required.

📁 Profile

1. Get Profile

  • Purpose: Retrieve user profile details.
  • Endpoint:
    GET {{BASE_URL}}/profile/{userId}
  • Authentication: Required.

2. Update Profile

  • Purpose: Update profile details like name or avatar.
  • Endpoint:
    PATCH {{BASE_URL}}/profile/{userId}
  • Request Body:
    {
      "firstName": "Updated Name",
      "lastName": "Updated Last Name"
    }
  • Authentication: Required.

3. Upload Avatar

  • Purpose: Upload a profile picture.
  • Endpoint:
    POST {{BASE_URL}}/profile/{userId}/avatar
  • Authentication: Required.

This document outlines the basic API functionality. Stick to documented endpoints for stability.