This release marks a new major version of http-status-codes.
Improvements include:
- Project rewritten in TypeScript
- TypeScript enums "StatusCodes" and "ReasonPhrases"
- Test coverage
- Automated source code generation of codes and documentation
- Change the reason phrase "Server Error" to the correct one, "Internal Server Error"
- Rename "getStatusText" -> "getReasonPhrase" to make the API more consistent
Thanks to @seanmhanson for their help on this new version.
Migrating from v1.x.x
http-status-codes v2 is mostly backwards compatible with v1. There is a single breaking change and two recommended changes.
[Breaking Change] 'Server Error'
The reason phrase for the status code 500
has been changed from "Server Error"
to "Internal Server Error"
. This is the correct phrase according to RFC7231. If you are migrating from v1, and have code that relies on the result of getStatusText(500)
or getReasonPhrase('Server Error')
, then this could affect you.
[Non-breaking change] getStatusText renamed getReasonPhrase
The function getStatusText
has been renamed to getReasonPhrase
. The old function is still available, but may be deprecated in a future version. To fix this simply rename instances of getStatusText()
to getReasonPhrase()
. The function is otherwise the same as it was before.
[Non-breaking change] StatusCodes
In http-status-codes v1, Status Codes were exported directly from the top-level module. i.e. HttpStatus.OK
. In v2 all Status Codes live under an object called StatusCodes
. i.e. HttpStatus.StatusCodes.OK
. We made this change to cater to TypeScript users who prefer a dedicated value with an enum type. The previous values are still exported, but we won't continue to update them. Please migrate if you're using the old-style imports.