The `statuses` package provides a comprehensive utility for working with HTTP status codes and messages in Node.js environments. It consolidates status information from official sources like the IANA Status Code Registry, as well as common implementations from the Node.js, NGINX, and Apache HTTP Server projects. Currently at stable version 2.0.2, the library maintains a steady release cadence focused on stability, minor updates, and continuous integration improvements rather than frequent feature additions, reflecting its role as a mature, low-level building block. Its key differentiator lies in its comprehensive data source aggregation and direct mapping capabilities, allowing developers to easily convert between numeric codes and descriptive messages, and access properties like whether a status indicates an empty body, a redirect, or a retryable condition. Unlike some HTTP utilities, `statuses` will throw an error for unknown codes or messages, ensuring strict adherence to recognized HTTP semantics.
npm install statusesVerified import paths — ran on the pinned version, not inferred.
Demonstrates core functionality including code-to-message and message-to-code lookups, accessing status code lists and properties like `empty` and `redirect`, and error handling for unknown values.
Always wrap calls to `status()` with a `try...catch` block if user-provided input might result in an unknown code or message, or pre-validate input against `status.codes` or `status.message`.
Avoid using status code 306. If encountered, handle it as an exceptional case or map it to a supported redirect code if appropriate.
For ESM, import the default export (e.g., `import status from 'statuses';`) and then access its properties (e.g., `status.codes`).
The 306 status code is not supported. Use recognized HTTP status codes. Wrap lookups in a try-catch if codes are dynamic.
Ensure the status message string is a valid, recognized HTTP status message (e.g., 'Forbidden', 'Not Found'). Wrap lookups in a try-catch if messages are dynamic.
Import the default export first, then access its properties: `import status from 'statuses'; console.log(status.codes);`
No dependency data recorded yet.