This package provides a comprehensive, TypeScript-first solution for working with HTTP status codes in JavaScript and Node.js applications. It offers a structured approach to access HTTP status code constants, retrieve human-readable names, and categorize codes into their respective classes (e.g., informational, success, client error, server error). The current stable version is 1.1.3, released in December 2022. While its release cadence has been infrequent, focusing primarily on bug fixes and minor dependency updates, the library remains a reliable choice for static HTTP status code mapping. Key differentiators include its robust TypeScript typings, which ensure compile-time safety and better developer experience, and its utility functions that simplify common operations like checking status categories, providing an abstract layer over raw numerical comparisons. It serves as a lightweight and focused alternative to manually managing HTTP status code logic.
npm install http-response-statusVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to check specific HTTP status codes, retrieve their human-readable names, and categorize them using the provided constants and utility functions for robust response handling.
Always import directly from the package root: `import { ... } from 'http-response-status'`. Avoid referencing internal file paths to ensure compatibility with future updates.Ensure consistent module usage within your project. For Node.js projects, set `"type": "module"` in `package.json` for ESM, or use `const { Name } = require('http-response-status');` for CJS environments.Understand that this package is purely for reference and utility around standard HTTP status codes, not for network requests or server-side routing directly. Integrate it with your existing HTTP client/server libraries.
For CommonJS, use `const { NHttpStatuses } = require('http-response-status');`. Alternatively, switch your project to ES Modules and use `import { NHttpStatuses } from 'http-response-status';`.Verify your project's module type configuration (`"type": "module"` in `package.json` for ESM) and your bundler settings. If targeting older Node.js or CJS, use `const { getHttpStatusName } = require('http-response-status');`.No dependency data recorded yet.