Skip to content

mime-types-lite

A small, zero-dependency TypeScript library of MIME constants and helpers for HTTP APIs, uploads, and file extensions.

Role
Library design and package engineering
Scope
Typed APIs, compatibility, and package distribution
Status
Published npm package

Problem

Upload, download, and HTTP code needs dependable mappings between filenames or extensions and media types. Carrying a broad MIME database into every bundle for that job adds weight most applications do not need.

Constraints

  1. C1

    One extension can have aliases or ambiguous mappings.

  2. C2

    Lookup must normalize case, dots, and paths without implying that file content was inspected.

  3. C3

    ESM and CommonJS consumers need stable typed exports with no runtime dependencies.

Architecture

A curated media-type registry backs pure lookup and validation functions, which are built with tsup into a dual-format package with typed exports. A TanStack Start docs and playground app in the same workspace runs against the local package.

01

Core library

A curated media-type registry backs pure functions for lookup and validation.

02

Package builds

The package is built with tsup into dual ESM and CommonJS formats with typed exports.

03

Documentation app

A workspace-linked TanStack Start app provides documentation and a playground that run against the local package.

Decisions

D1

Keep the scope narrow and dependency-free

A curated registry and a small set of helpers cover common upload and HTTP needs without a broad database dependency, at the cost of not covering every registered type.

D2

Treat extension lookup as metadata, not security

A filename only suggests a media type. The library never inspects file bytes, so callers should not mistake a lookup for content validation.

D3

Test the local package from the docs app

The documentation app runs the exact package that will be released, so examples and behavior are checked against the real build before publishing.

Contribution

  • Implemented extension-to-type and type-to-extension lookups.
  • Added normalization and validation helpers.
  • Configured typed ESM and CommonJS publishing.
  • Built interactive docs, examples, tests, CI, and Netlify deployment.

Outcomes

  • Consumers can infer common media types from filenames.
  • Consumers can recover the preferred extension for a media type.
  • Media-type inputs can be validated and normalized before use.
  • The same API works in browser and Node.js module systems.

Product screenshot

mime-types-lite documentation home page with the headline 'Know what you're sending' and a lookup example
The documentation app looks up media types with the same local package that ships to npm.

Verified stack

  • TypeScript
  • ESM
  • CommonJS
  • tsup
  • TanStack Start
  • React
  • Tailwind CSS
  • Vite
  • Netlify
  • GitHub Actions
  • CI/CD
  • System Design

Working through something similar?

Share your challenge, scope, and timeline to start a focused conversation.