EaseMargin API Documentation

Version: 1.0.0, EC2 INSTANCE, AWS
Last Updated: 5th Aug, 2024
Author: Rahul Deo Burman

Introduction

Welcome to the API documentation for our service, built using Node.js, Express.js, and MySQL. This API provides a robust and efficient way to interact with our database, allowing you to perform various operations such as creating, reading, updating, and deleting (CRUD) records.


Technology Stack

Node.js

Node.js is a powerful JavaScript runtime built on Chrome's V8 engine, allowing us to build scalable network applications. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications.

Express.js

Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications. It facilitates the rapid development of Node-based web applications by providing a set of features to help with routing, middleware integration, and handling HTTP requests and responses.

MySQL

MySQL is a popular relational database management system known for its reliability, performance, and ease of use. It is used to manage and store the data for this API, providing a structured way to organize and query data efficiently.

Overview

This API allows you to:

  • Create new records in the database.
  • Read existing records from the database.
  • Update existing records in the database.
  • Delete records from the database.

Each endpoint in this API is designed to handle specific operations on the data, ensuring a clear and organized approach to interacting with our service.

Base URL

The base URL for accessing the API is:

https://api.yourdomain.com:8080

All endpoints described in this documentation are relative to this base URL.

Authentication

To access the API, you will need to authenticate using an API key. The API key should be included in the header of each request as follows:

Authorization: Bearer YOUR_API_KEY

Getting Started

Clone the repository with the link given below, if you have invitation link

https://github.com/Streamlineadmin/streamline-backend.git


(base) burman@Rahuls-MacBook-Pro ~ % git clone https://github.com/Streamlineadmin/streamline-backend.git

(base) burman@Rahuls-MacBook-Pro ~ % cd streamline-backend

(base) burman@Rahuls-MacBook-Pro streamline-backend ~ % npm install

(base) burman@Rahuls-MacBook-Pro streamline-backend ~ % npm start

[nodemon] starting `node server.js`
Server running at http://localhost:8080

Signup Endpoint

The signup endpoint allows new users to create an account by providing the necessary information. Below is the detailed information on how to use this endpoint.

Endpoint

POST: http://localhost:8080/authentication/signup

Request Headers

  • Content-Type: application/json

Request Body

The request body should be a JSON object containing the following fields:

  • name (string, required): Full name of the user.
  • username (string, required): The desired username for the new account.
  • email (string, required): The user's email address.
  • password (string, required): The password for the new account.

Example Request Body

                    
                        {
                            "name": "Rahul Burman",
                            "username": "rdburman",
                            "email": "rdeoburman@gmail.com",
                            "password": "demopassword"
                        }
                    
                

Response

The response will be a JSON object containing the following fields:

  • message (string): A message providing additional information about the signup result.

Example Successful Response

                    
                        {
                            "message": "Signed up successfully"
                        }
                    
                

Example Error Response

                    
                        {
                            "message": "Email already exists !"
                        }
                    
                

Error Handling

Our API uses standard HTTP status codes to indicate the success or failure of an API request. Here are some common status codes you may encounter:

  • 200 OK: The request was successful.
  • 201 Created: A new resource was successfully created.
  • 400 Bad Request: The request was invalid or cannot be otherwise served.
  • 401 Unauthorized: Authentication is required and has failed or has not yet been provided.
  • 404 Not Found: The requested resource could not be found.
  • 500 Internal Server Error: An error occurred on the server.

Error Codes

Common error codes you may encounter include:

  • 400 Bad Request: The request was invalid or cannot be otherwise served. This may occur if required fields are missing or if the password and confirmPassword do not match.
  • 409 Conflict: The request could not be completed due to a conflict with the current state of the target resource. This may occur if the email or username is already in use.
  • 500 Internal Server Error: An error occurred on the server.