The `http-constants-ts` library provides a comprehensive collection of standardized and commonly used non-standard HTTP constants, including headers, MIME types, tracking statuses, HTTP methods, content encodings, CSP directives and sources, HTTP response codes, and Cache-Control instructions. Currently stable at version 1.0.8, its release cadence is typically slow, reflecting the stable nature of HTTP specifications, with updates primarily driven by new RFCs or significant industry changes. A key differentiator is its TypeScript-first design, offering strong type safety and predictable access patterns through structured objects like `Headers.STRICT_TRANSPORT_SECURITY` or `MimeTypes.Application.JSON`. It ensures consistency by normalizing constant values: headers are capitalized (e.g., `Strict-Transport-Security`), MIME types, content encodings, and cache-control instructions are lowercase (e.g., `application/json`, `deflate`, `max-age`), and HTTP methods are uppercase (e.g., `POST`), reducing the chance of runtime errors from 'magic strings'.
npm install http-constants-tsVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing and using various HTTP constants like headers, MIME types, response codes, and methods, showing how to access their structured values in a type-safe manner.
Always refer to the library's internal key names as documented or inferred by TypeScript's intellisense (e.g., `Headers.CONTENT_TYPE`, not `Headers['Content-Type']`).
Be aware of the expected casing when using the constant values in contexts that are case-sensitive. The library provides the correct string literal for each constant.
Prefer `import ... from 'http-constants-ts'` syntax. Ensure your project's `tsconfig.json` and `package.json` are configured for modern module resolution (e.g., `"type": "module"` in `package.json`, `"module": "esnext"` in `tsconfig.json`).
Access constants using the library's predefined keys, which typically convert hyphens to underscores and use uppercase for names (e.g., `Headers.CONTENT_TYPE` for `Content-Type`).
Use ESM `import` statements: `import { Headers } from 'http-constants-ts';`. Ensure your `package.json` has `"type": "module"` if running directly in Node.js, or your bundler is configured correctly.No dependency data recorded yet.