Skip to content

content-types-lite

packageLast commit

Tiny, type-safe HTTP media type constants and utilities for parsing, formatting, matching, and validation.

Role
Library design and package engineering
Scope
Typed APIs, compatibility, and package distribution
Status
Published npm package
content-types-lite interface preview

Problem

Applications repeatedly implement subtly different Content-Type parsing and negotiation logic or import larger dependency trees for a focused HTTP-header task.

Constraints

  1. C1

    Quoted parameters and malformed header values need predictable parsing.

  2. C2

    Package output must work across ESM and CommonJS consumers.

  3. C3

    The public API must stay small and type-safe without runtime dependencies.

Architecture

Pure TypeScript library and tests; dual ESM/CommonJS build/exports; workspace-linked React documentation/playground that consumes the local package.

01

Core library

Pure TypeScript library and tests.

02

Package builds

Dual ESM/CommonJS build/exports.

03

Documentation app

Workspace-linked React documentation/playground that consumes the local package.

Decisions

D1

Keep runtime dependencies at zero

Keep runtime dependencies at zero, trading broad convenience helpers for a focused surface.

D2

Ship dual module formats with typed exports

Ship dual module formats with typed exports.

D3

Colocate docs playground and package

Colocate docs playground and package so every app build exercises the workspace implementation.

Contribution

  • Implemented media-type parsing/formatting and parameter handling.
  • Added content negotiation/validation helpers and type declarations.
  • Configured tsup/package exports and release gates.
  • Built searchable interactive docs/examples against workspace:*.

Outcomes

  • Consumers can parse and serialize Content-Type values.
  • Validate/compare media types.
  • Use the package from ESM or CommonJS.
  • Test behavior interactively in the documentation app.

Product screenshot

content-types-lite interface preview
content-types-lite presents tiny, type-safe HTTP media type constants and utilities for parsing, formatting, matching, and validation.

Verified stack

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

Working through something similar?

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