GithubHelp home page GithubHelp logo

nipun221 / heliverse Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 166 KB

The MERN stack powers our Admin Dashboard, a dynamic and efficient solution for streamlined management. With MongoDB, Express.js, React, and Node.js, it ensures a seamless user experience, providing comprehensive control and insights in a responsive and intuitive interface.

Home Page: https://heliverse-phi.vercel.app

JavaScript 86.59% HTML 0.40% CSS 13.00%

heliverse's Introduction

OAdmin

Website is hosted at = https://heliverse-phi.vercel.app/

OAdmin API Documentation

Overview

The OAdmin API provides endpoints to manage a collection of mock user data. Users can be retrieved, created, updated, and deleted. The API supports various queries such as pagination, searching, and filtering based on different parameters.

Base URL

The base URL for the API is http://localhost:{PORT}, where {PORT} is the port number specified during the server setup.

Authentication

To access certain endpoints, authentication is required. Users need to include a valid JWT (JSON Web Token) in the Authorization header of the HTTP request.

JWT Generation

A JWT can be generated by logging in through the /api/users/login endpoint. The generated token must then be included in the header for subsequent authenticated requests.

Endpoints

User Registration

  • Endpoint: POST /api/users/register
  • Description: Register a new user.
  • Request Body:
    • username (string): User's username (minimum length: 3 characters).
    • email (string): User's email address.
    • password (string): User's password (minimum length: 8 characters).
  • Response:
    • 201 Created: User successfully registered.
    • 400 Bad Request: Invalid request or missing data.
    • 422 Unprocessable Entity: Invalid data.

User Login

  • Endpoint: POST /api/users/login
  • Description: Authenticate user and generate a JWT for further access.
  • Request Body:
    • username (string): User's username.
    • password (string): User's password (minimum length: 8 characters).
  • Response:
    • 200 OK: Successful login. Returns user information and JWT.
    • 401 Unauthorized: Invalid username or password.
    • 404 Not Found: User not found.
    • 400 Bad Request: Invalid request or missing data.
    • 422 Unprocessable Entity: Invalid data.

Get All Users

  • Endpoint: GET /api/users
  • Description: Retrieve a paginated list of all users.
  • Query Parameters:
    • page (optional, default: 1): Page number.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful retrieval. Returns user information and pagination details.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 500 Internal Server Error: Server error.

Create User

  • Endpoint: POST /api/users
  • Description: Create a new user.
  • Request Body: User data.
  • Authentication: Required (JWT).
  • Response:
    • 201 Created: User successfully created.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 500 Internal Server Error: Server error.

Get User by ID

  • Endpoint: GET /api/users/:id
  • Description: Retrieve user details by user ID.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful retrieval. Returns user information.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 404 Not Found: User not found.
    • 500 Internal Server Error: Server error.

Update User by ID

  • Endpoint: PUT /api/users/:id
  • Description: Update user details by user ID.
  • Request Body: Updated user data.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful update. Returns updated user information.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 404 Not Found: User not found.
    • 500 Internal Server Error: Server error.

Delete User by ID

  • Endpoint: DELETE /api/users/:id
  • Description: Delete a user by user ID.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful deletion. Returns deleted user information.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 404 Not Found: User not found.
    • 500 Internal Server Error: Server error.

Get Users by Domain

  • Endpoint: GET /api/users/domain/:domain
  • Description: Retrieve users by domain with pagination.
  • Query Parameters:
    • page (optional, default: 1): Page number.
    • pageSize (optional, default: 20): Number of users per page.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful retrieval. Returns user information and pagination details.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 500 Internal Server Error: Server error.

Get Users by Availability

  • Endpoint: GET /api/users/available/:available
  • Description: Retrieve users by availability with pagination.
  • Query Parameters:
    • page (optional, default: 1): Page number.
    • pageSize (optional, default: 20): Number of users per page.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful retrieval. Returns user information and pagination details.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 500 Internal Server Error: Server error.

Get Users by Gender

  • Endpoint: GET /api/users/gender/:gender
  • Description: Retrieve users by gender with pagination.
  • Query Parameters:
    • page (optional, default: 1): Page number.
    • pageSize (optional, default: 20): Number of users per page.
  • Authentication: Required (JWT).
  • **Response

:**

  • 200 OK: Successful retrieval. Returns user information and pagination details.
  • 401 Unauthorized: Token not provided.
  • 403 Forbidden: Invalid token.
  • 500 Internal Server Error: Server error.

Search Users by String

  • Endpoint: GET /api/users/search/:string
  • Description: Search users by string with pagination.
  • Query Parameters:
    • page (optional, default: 1): Page number.
  • Authentication: Required (JWT).
  • Response:
    • 200 OK: Successful retrieval. Returns user information and pagination details.
    • 401 Unauthorized: Token not provided.
    • 403 Forbidden: Invalid token.
    • 500 Internal Server Error: Server error.

Error Handling

In case of errors, the API returns an appropriate HTTP status code along with a JSON response containing details about the error.

Example Error Response:

{
  "error": "Unauthorized: Token not provided"
}

Pagination

The API supports pagination for retrieving lists of users. The response includes information about the total number of users, the current page, and links for navigation to the next and previous pages.

Example Pagination Information:

{
  "numberOfUsers": 10,
  "totalPages": 2,
  "currentPage": 1,
  "users": [...],
  "links": {
    "self": "/api/users?page=1",
    "next": "/api/users?page=2",
    "prev": null
  }
}

Query Parameters

Various query parameters are supported for specific endpoints to filter and customize the results. Refer to individual endpoint descriptions for details on supported query parameters.

Conclusion

This API provides a simple and flexible way to manage mock user data. Developers can integrate these endpoints into their applications to perform CRUD operations on user records, with support for authentication, pagination, and querying based on different parameters.

heliverse's People

Contributors

nipun221 avatar

Stargazers

Phạm Ngọc Vân avatar

Watchers

 avatar

Forkers

tejxv

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.