The content-types-lite is a lightweight and structured utility providing standardized content types (MIME types) for various applications. It simplifies content type handling by offering predefined constants, ensuring consistency in file processing, API responses, and HTTP headers.
- Predefined Content Types: A comprehensive set of MIME types categorized for different use cases.
- TypeScript Support: Strong type definitions for better development experience and safety.
- Immutable Constants: Prevents modifications to ensure consistency.
- Lightweight & Efficient: Optimized for performance with a minimal footprint.
- Seamless Integration: Works with any Node.js or TypeScript-based project.
To install the package, run the following command:
npm install content-types-liteor
yarn add content-types-liteor
pnpm add content-types-liteor
bun add content-types-liteconst contentTypesLite = require('content-types-lite');
console.log(contentTypesLite.JSON); // Outputs: application/jsonimport contentTypesLite from 'content-types-lite';
console.log(contentTypesLite.JSON); // Outputs: application/json
const fileType = 'JSON';
console.log(contentTypesLite[fileType]); // Outputs: application/jsonimport contentTypesLite, { ContentType } from 'content-types-lite';
console.log(contentTypesLite.JSON); // Outputs: application/json
const fileType: ContentType = 'JSON';
console.log(contentTypesLite[fileType]); // Outputs: application/jsonPLAIN_TEXT:text/plainHTML:text/htmlCSS:text/cssCSV:text/csvXML:text/xmlMARKDOWN:text/markdownRICH_TEXT:text/richtext
JSON:application/jsonXML_APP:application/xmlYAML:application/x-yamlFORM_URLENCODED:application/x-www-form-urlencodedNDJSON:application/x-ndjsonMSGPACK:application/x-msgpackPROTOBUF:application/x-protobuf
MULTIPART_FORM_DATA:multipart/form-dataMULTIPART_MIXED:multipart/mixedMULTIPART_ALTERNATIVE:multipart/alternativeMULTIPART_DIGEST:multipart/digestMULTIPART_RELATED:multipart/relatedMULTIPART_SIGNED:multipart/signedMULTIPART_ENCRYPTED:multipart/encrypted
OCTET_STREAM:application/octet-streamPDF:application/pdfZIP:application/zipGZIP:application/gzipMSWORD:application/mswordDOCX:application/vnd.openxmlformats-officedocument.wordprocessingml.documentEXCEL:application/vnd.ms-excelXLSX:application/vnd.openxmlformats-officedocument.spreadsheetml.sheetPOWERPOINT:application/vnd.ms-powerpointPPTX:application/vnd.openxmlformats-officedocument.presentationml.presentation
GIF:image/gifPNG:image/pngJPEG:image/jpegWEBP:image/webpSVG:image/svg+xmlHEIF:image/heifAVIF:image/avif
EVENT_STREAM:text/event-streamTAR:application/x-tarBZIP2:application/x-bzip2
This project is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).
- Share — Copy and redistribute the material in any medium or format.
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
- NonCommercial — You may not use the material for commercial purposes.
- NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material.
For more details, please visit the Creative Commons License Page.
Special thanks to the following resources:
- MDN Web Docs - Comprehensive MIME type references.
- Node.js Express Documentation - Guidance on handling content types in HTTP responses.
- TypeScript Docs - Best practices for defining and using type-safe constants.
Content types are categorized based on their format. Documents, images, videos, and binary files each have their respective content types. Refer to the Supported Content Types section for details.
No, the constants are immutable and follow the official content type standards. If needed, you can create a wrapper module to include your custom content types.
You can remove the package by running:
npm uninstall content-types-liteor
yarn remove content-types-liteor
pnpm remove content-types-liteor
bun remove content-types-lite|
M♢NTΛSIM |
