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-lite
const mimeTypesLite = require('mime-types-lite');
console.log(mimeTypesLite.JSON); // Outputs: application/json
import mimeTypesLite from 'mime-types-lite';
console.log(mimeTypesLite.JSON); // Outputs: application/json
// TypeScript example:
import mimeTypesLite, { MimeType } from 'mime-types-lite';
const fileType: MimeType = 'JSON';
console.log(mimeTypesLite[fileType]); // Outputs: application/json
import 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+zip
-
TEX
:application/x-tex
-
PPT
:application/vnd.ms-powerpoint
-
PPTX
:application/vnd.openxmlformats-officedocument.presentationml.presentation
-
ODT
:application/vnd.oasis.opendocument.text
-
ODS
:application/vnd.oasis.opendocument.spreadsheet
-
RTF
:application/rtf
-
DOC
:application/msword
-
DOCX
:application/vnd.openxmlformats-officedocument.wordprocessingml.document
-
XLS
:application/vnd.ms-excel
-
XLSX
:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
-
PDF
:application/pdf
-
MD
:text/markdown
-
TXT
:text/plain
-
CSV
:text/csv
-
XCF
:image/x-xcf
-
PSD
:image/vnd.adobe.photoshop
-
JP2
:image/jp2
-
AVIF
:image/avif
-
HEIC
:image/heic
-
WEBP
:image/webp
-
JPG
:image/jpeg
-
JPEG
:image/jpeg
-
PNG
:image/png
-
ICO
:image/x-icon
-
GIF
:image/gif
-
BMP
:image/bmp
-
TIFF
:image/tiff
-
SVG
:image/svg+xml
-
MKV
:video/x-matroska
-
FLV
:video/x-flv
-
WMV
:video/x-ms-wmv
-
MOV
:video/quicktime
-
WEBM
:video/webm
-
AVI
:video/avi
-
MPEG
:video/mpeg
-
MP4
:video/mp4
-
AMR
:audio/amr
-
MIDI
:audio/midi
-
FLAC
:audio/flac
-
OGG
:audio/ogg
-
AAC
:audio/aac
-
MP3
:audio/mpeg
-
WAV
:audio/wav
-
TAR
:application/x-tar
-
GZ
:application/gzip
-
SEVEN_ZIP
:application/x-7z-compressed
-
ZIP
:application/zip
-
RAR
:application/vnd.rar
-
BZ2
:application/x-bzip2
-
ICS
:text/calendar
-
ATOM
:application/atom+xml
-
RSS
:application/rss+xml
-
WASM
:application/wasm
-
YAML
:application/x-yaml
-
GRAPHQL
:application/graphql
-
URL_ENCODED
:application/x-www-form-urlencoded
-
JSON
:application/json
-
XML
:application/xml
-
JS
:application/javascript
-
CSS
:text/css
-
HTML
:text/html
-
WOFF
:font/woff
-
WOFF2
:font/woff2
-
TTF
:font/ttf
-
OTF
:font/otf
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 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 |