http-status-enum is a lightweight JavaScript/TypeScript library designed to provide a comprehensive, read-only enumeration of standard HTTP status codes. It offers a convenient dual-access mechanism, allowing developers to retrieve status descriptions from numeric codes (e.g., `500` yields `INTERNAL_SERVER_ERROR`) and vice-versa. The package is currently stable at version 1.0.2, with a slow, maintenance-focused release cadence primarily addressing module resolution and type definition correctness. Its key differentiators include its minimal footprint, explicit TypeScript type definitions for enhanced developer experience and type safety, and its straightforward API for consistent access to HTTP status information without external dependencies or complex configurations, making it a reliable choice for various application contexts.
npm install http-status-enumVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the enum, accessing status codes by number and description, and a practical use case in response handling.
Upgrade to version 1.0.1 or higher. If using `require()`, ensure you access the `.default` property for the ESM default export.
Upgrade to version 1.0.2 or higher to ensure correct type resolution and definition files are used by TypeScript.
Treat the imported `HTTP_STATUS_CODES` object as immutable. If custom status codes are needed, define a separate object or extend it carefully in your application's scope.
Upgrade to `http-status-enum@1.0.2` or newer. Ensure your `tsconfig.json` has appropriate `moduleResolution` settings (e.g., `Node` or `Bundler`). For CommonJS, use `require('http-status-enum').default`.Ensure your `tsconfig.json` correctly handles `esModuleInterop` and `allowSyntheticDefaultImports`. For modern Node.js and bundlers, prefer `import HTTP_STATUS_CODES from 'http-status-enum';` (ESM) over `require()` where possible.
Use a type assertion: `HTTP_STATUS_CODES[someStringVariable as keyof typeof HTTP_STATUS_CODES]` or validate the string against the enum keys if it comes from user input.
No dependency data recorded yet.