Last active
January 28, 2025 08:28
-
-
Save montasim/dbf61648069cd19cde236fd435ed9170 to your computer and use it in GitHub Desktop.
Defines the various HTTP methods used in the application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Defines the various HTTP methods used in the application. | |
* This module exports an object that contains the different HTTP methods | |
* the application can handle. These methods are used to configure | |
* the application behavior based on the current HTTP method. | |
* | |
* @module constants/httpMethods | |
* @version 1.0.0 | |
* @license CC BY-NC-ND 4.0 | |
* | |
* @contact Mohammad Montasim -Al- Mamun Shuvo | |
* @created 2025-01-28 | |
* @contactEmail [email protected] | |
* @contactGithub https://github.com/montasim | |
*/ | |
/** | |
* An object representing different HTTP methods. | |
* @enum {string} | |
*/ | |
const httpMethodsConstants = Object.freeze({ | |
/** | |
* GET method - Used to retrieve data from the server. | |
* Example: A client sends a GET request to `/api/users` to fetch a list of users. | |
* @type {string} | |
*/ | |
GET: 'GET', | |
/** | |
* POST method - Used to submit data to the server to create a new resource. | |
* Example: A client sends a POST request to `/api/users` with user details to create a new user. | |
* @type {string} | |
*/ | |
POST: 'POST', | |
/** | |
* PUT method - Used to update or replace an existing resource on the server. | |
* Example: A client sends a PUT request to `/api/users/123` to update the details of user with ID 123. | |
* @type {string} | |
*/ | |
PUT: 'PUT', | |
/** | |
* DELETE method - Used to delete a resource from the server. | |
* Example: A client sends a DELETE request to `/api/users/123` to remove the user with ID 123. | |
* @type {string} | |
*/ | |
DELETE: 'DELETE', | |
/** | |
* OPTIONS method - Used to describe the communication options for the target resource. | |
* Example: A client sends an OPTIONS request to `/api/users` to determine the allowed HTTP methods (e.g., GET, POST). | |
* @type {string} | |
*/ | |
OPTIONS: 'OPTIONS', | |
/** | |
* HEAD method - Used to retrieve the headers of a resource without the body. | |
* Example: A client sends a HEAD request to `/api/users` to check the response headers (e.g., content type, length) without fetching the body. | |
* @type {string} | |
*/ | |
HEAD: 'HEAD', | |
/** | |
* PATCH method - Used to apply partial updates to a resource on the server. | |
* Example: A client sends a PATCH request to `/api/users/123` with a JSON payload to update only the email of the user with ID 123. | |
* @type {string} | |
*/ | |
PATCH: 'PATCH', | |
/** | |
* CONNECT method - Used to establish a tunnel to the server identified by the target resource. | |
* Example: A client sends a CONNECT request to a proxy server to create an HTTPS tunnel for secure communication. | |
* @type {string} | |
*/ | |
CONNECT: 'CONNECT', | |
/** | |
* TRACE method - Used to perform a message loop-back test along the path to the target resource. | |
* Example: A client sends a TRACE request to `/api/users` to debug or trace how the request is handled by intermediate servers. | |
* @type {string} | |
*/ | |
TRACE: 'TRACE', | |
}); | |
export default httpMethodsConstants; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment