The mime-types-lite is a lightweight and comprehensive utility providing standardized MIME types for applications. It simplifies the handling of file format identification by offering predefined constants, ensuring clarity and consistency in file processing and serving.
- Predefined MIME Types: Provides a comprehensive set of MIME types for easy reference.
- TypeScript Support: Includes strong type definitions for enhanced code safety and developer experience.
- Immutable Constants: Ensures MIME types cannot be modified, preventing unintended changes.
- Lightweight & Efficient: Minimal footprint with high performance.
- Easy Integration: Seamlessly integrates with any Node.js or TypeScript-based project.
To install the package, run the following command:
npm install mime-types-liteimport mimeTypesLite from 'mime-types-lite';
console.log(mimeTypesLite.JSON); // Outputs: application/jsonimport mimeTypesLite, { MimeType } from 'mime-types-lite';
const fileType: MimeType = 'JSON';
console.log(mimeTypesLite[fileType]); // Outputs: application/jsonimport mimeTypesLite from 'mime-types-lite';
const express = require('express');
const app = express();
app.get('/file', (req, res) => {
res.setHeader('Content-Type', mimeTypesLite.PDF);
res.send('This is a PDF response');
});
app.listen(3000, () => console.log('Server running on port 3000'));EPUB:application/epub+zipTEX:application/x-texPPT:application/vnd.ms-powerpointPPTX:application/vnd.openxmlformats-officedocument.presentationml.presentationODT:application/vnd.oasis.opendocument.textODS:application/vnd.oasis.opendocument.spreadsheetRTF:application/rtfDOC:application/mswordDOCX:application/vnd.openxmlformats-officedocument.wordprocessingml.documentXLS:application/vnd.ms-excelXLSX:application/vnd.openxmlformats-officedocument.spreadsheetml.sheetPDF:application/pdfMD:text/markdownTXT:text/plainCSV:text/csv
XCF:image/x-xcfPSD:image/vnd.adobe.photoshopJP2:image/jp2AVIF:image/avifHEIC:image/heicWEBP:image/webpJPG:image/jpegPNG:image/pngICO:image/x-iconGIF:image/gifBMP:image/bmpTIFF:image/tiffSVG:image/svg+xml
MKV:video/x-matroskaFLV:video/x-flvWMV:video/x-ms-wmvMOV:video/quicktimeWEBM:video/webmAVI:video/aviMPEG:video/mpegMP4:video/mp4
AMR:audio/amrMIDI:audio/midiFLAC:audio/flacOGG:audio/oggAAC:audio/aacMP3:audio/mpegWAV:audio/wav
TAR:application/x-tarGZ:application/gzipSEVEN_ZIP:application/x-7z-compressedZIP:application/zipRAR:application/vnd.rarBZ2:application/x-bzip2
ICS:text/calendarATOM:application/atom+xmlRSS:application/rss+xmlWASM:application/wasmYAML:application/x-yamlGRAPHQL:application/graphqlURL_ENCODED:application/x-www-form-urlencodedJSON:application/jsonXML:application/xmlJS:application/javascriptCSS:text/cssHTML:text/html
WOFF:font/woffWOFF2:font/woff2TTF:font/ttfOTF:font/otf
This project is licensed under the CC BY-NC-ND 4.0.
Special thanks to the following resources:
- MDN Web Docs - Comprehensive MIME type references.
- Node.js Express Documentation - Guidance on handling MIME types in HTTP responses.
- TypeScript Docs - Best practices for defining and using type-safe constants.
MIME types are categorized based on their format. Documents, images, videos, audio, and archives each have their respective MIME types. Refer to the Supported MIME Types section for details.
No, the constants are immutable and follow the official MIME type standards. If needed, you can create a wrapper module to include your custom MIME types.
You can remove the package by running:
npm uninstall mime-types-lite|
M♢NTΛSIM |