Skip to content

Instantly share code, notes, and snippets.

@montasim
Last active January 28, 2025 08:28
Show Gist options
  • Save montasim/c617ab1e4dba33de7d01063f5b0175a7 to your computer and use it in GitHub Desktop.
Save montasim/c617ab1e4dba33de7d01063f5b0175a7 to your computer and use it in GitHub Desktop.
Defines the various content types used in the application.
/**
* @fileoverview Defines the various content types used in the application.
* This module exports an object that contains the different content types
* the application can handle. These content types are used to configure
* the application behavior based on the current content type.
*
* @module constants/contentTypes
* @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 content types.
* @enum {string}
*/
const contentTypesConstants = Object.freeze({
/**
* JSON content type - Used for sending and receiving JSON-encoded data.
* Example: A REST API response containing user data in JSON format.
* @type {string}
*/
JSON: 'application/json',
/**
* Form data content type - Used for submitting form data that includes files.
* Example: A file upload form that sends an image file to the server.
* @type {string}
*/
FORM_DATA: 'multipart/form-data',
/**
* URL encoded form data content type - Used for submitting form data in URL-encoded format.
* Example: A login form that sends username and password data.
* @type {string}
*/
X_WWW_FORM_URLENCODED: 'application/x-www-form-urlencoded',
/**
* Plain text content type - Used for sending plain text data.
* Example: A log message sent to a server as plain text.
* @type {string}
*/
TEXT_PLAIN: 'text/plain',
/**
* HTML content type - Used for sending HTML content.
* Example: A server sends an HTML page as the response to a browser request.
* @type {string}
*/
TEXT_HTML: 'text/html',
/**
* XML content type - Used for sending XML-encoded data.
* Example: A SOAP API request containing an XML payload.
* @type {string}
*/
APPLICATION_XML: 'application/xml',
/**
* JavaScript content type - Used for serving JavaScript files.
* Example: A server sends a JavaScript file requested by a web browser.
* @type {string}
*/
APPLICATION_JAVASCRIPT: 'application/javascript',
/**
* CSS content type - Used for serving CSS files.
* Example: A server sends a CSS file requested by a web browser.
* @type {string}
*/
TEXT_CSS: 'text/css',
/**
* CSV content type - Used for sending or downloading data in CSV format.
* Example: A server provides an export of user data as a CSV file.
* @type {string}
*/
TEXT_CSV: 'text/csv',
/**
* Binary data content type - Used for sending arbitrary binary data.
* Example: A server sends a binary file such as an executable or image file.
* @type {string}
*/
APPLICATION_OCTET_STREAM: 'application/octet-stream',
/**
* PDF content type - Used for serving PDF documents.
* Example: A server sends a PDF invoice to the client.
* @type {string}
*/
APPLICATION_PDF: 'application/pdf',
/**
* ZIP content type - Used for serving compressed ZIP files.
* Example: A server provides a ZIP archive for a software download.
* @type {string}
*/
APPLICATION_ZIP: 'application/zip',
/**
* GZIP content type - Used for serving compressed GZIP files.
* Example: A server sends a GZIP-compressed log file.
* @type {string}
*/
APPLICATION_GZIP: 'application/gzip',
/**
* Image PNG content type - Used for serving PNG image files.
* Example: A server serves a PNG profile picture to a client.
* @type {string}
*/
IMAGE_PNG: 'image/png',
/**
* Image JPEG content type - Used for serving JPEG image files.
* Example: A server serves a JPEG photo to a web page.
* @type {string}
*/
IMAGE_JPEG: 'image/jpeg',
/**
* Image GIF content type - Used for serving GIF image files.
* Example: A server serves an animated GIF as a part of a webpage.
* @type {string}
*/
IMAGE_GIF: 'image/gif',
/**
* Image BMP content type - Used for serving BMP image files.
* Example: A server delivers a BMP file for specialized image processing.
* @type {string}
*/
IMAGE_BMP: 'image/bmp',
/**
* Image SVG content type - Used for serving SVG vector graphics.
* Example: A server serves an SVG logo to be displayed on a website.
* @type {string}
*/
IMAGE_SVG_XML: 'image/svg+xml',
/**
* Audio MPEG content type - Used for serving MP3 audio files.
* Example: A music streaming service delivers an MP3 file to a client.
* @type {string}
*/
AUDIO_MPEG: 'audio/mpeg',
/**
* Audio OGG content type - Used for serving OGG audio files.
* Example: A podcast server streams an OGG audio file.
* @type {string}
*/
AUDIO_OGG: 'audio/ogg',
/**
* Video MP4 content type - Used for serving MP4 video files.
* Example: A video streaming service provides an MP4 video file.
* @type {string}
*/
VIDEO_MP4: 'video/mp4',
/**
* Video OGG content type - Used for serving OGG video files.
* Example: A server streams an OGG video to a client.
* @type {string}
*/
VIDEO_OGG: 'video/ogg',
});
export default contentTypesConstants;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment