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.

Revisions

  1. montasim revised this gist Jan 28, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions contentTypes.constants.js
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@
    * An object representing different content types.
    * @enum {string}
    */
    const contentTypesConstants = {
    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.
    @@ -172,6 +172,6 @@ const contentTypesConstants = {
    * @type {string}
    */
    VIDEO_OGG: 'video/ogg',
    };
    });

    export default contentTypesConstants;
  2. montasim revised this gist Jan 28, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion contentTypes.constants.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    *
    * @module constants/contentTypes
    * @version 1.0.0
    * @license MIT
    * @license CC BY-NC-ND 4.0
    *
    * @contact Mohammad Montasim-Al-Mamun Shuvo
    * @created 2025-01-28
  3. montasim revised this gist Jan 28, 2025. 1 changed file with 111 additions and 23 deletions.
    134 changes: 111 additions & 23 deletions contentTypes.constants.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    * @version 1.0.0
    * @license MIT
    *
    * @contact Mohammad Montasim -Al- Mamun Shuvo
    * @contact Mohammad Montasim-Al-Mamun Shuvo
    * @created 2025-01-28
    * @contactEmail [email protected]
    * @contactGithub https://github.com/montasim
    @@ -19,70 +19,158 @@
    * @enum {string}
    */
    const contentTypesConstants = {
    /** JSON content type */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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 */
    /**
    * 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',
    };

  4. montasim created this gist Jan 28, 2025.
    89 changes: 89 additions & 0 deletions contentTypes.constants.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    /**
    * @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 MIT
    *
    * @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 = {
    /** JSON content type */
    JSON: 'application/json',

    /** Form data content type */
    FORM_DATA: 'multipart/form-data',

    /** URL encoded form data content type */
    X_WWW_FORM_URLENCODED: 'application/x-www-form-urlencoded',

    /** Plain text content type */
    TEXT_PLAIN: 'text/plain',

    /** HTML content type */
    TEXT_HTML: 'text/html',

    /** XML content type */
    APPLICATION_XML: 'application/xml',

    /** JavaScript content type */
    APPLICATION_JAVASCRIPT: 'application/javascript',

    /** CSS content type */
    TEXT_CSS: 'text/css',

    /** CSV content type */
    TEXT_CSV: 'text/csv',

    /** Binary data content type */
    APPLICATION_OCTET_STREAM: 'application/octet-stream',

    /** PDF content type */
    APPLICATION_PDF: 'application/pdf',

    /** ZIP content type */
    APPLICATION_ZIP: 'application/zip',

    /** GZIP content type */
    APPLICATION_GZIP: 'application/gzip',

    /** Image PNG content type */
    IMAGE_PNG: 'image/png',

    /** Image JPEG content type */
    IMAGE_JPEG: 'image/jpeg',

    /** Image GIF content type */
    IMAGE_GIF: 'image/gif',

    /** Image BMP content type */
    IMAGE_BMP: 'image/bmp',

    /** Image SVG content type */
    IMAGE_SVG_XML: 'image/svg+xml',

    /** Audio MPEG content type */
    AUDIO_MPEG: 'audio/mpeg',

    /** Audio OGG content type */
    AUDIO_OGG: 'audio/ogg',

    /** Video MP4 content type */
    VIDEO_MP4: 'video/mp4',

    /** Video OGG content type */
    VIDEO_OGG: 'video/ogg',
    };

    export default contentTypesConstants;