https://github.com/dev-rashedin/http-status-toolkit
Lightweight, fully typed TypeScript utility for HTTP status codes, with enums, categorized utilities, and helper functions to improve developer experience.
https://github.com/dev-rashedin/http-status-toolkit
dx http status-codes typescript
Last synced: about 2 months ago
JSON representation
Lightweight, fully typed TypeScript utility for HTTP status codes, with enums, categorized utilities, and helper functions to improve developer experience.
- Host: GitHub
- URL: https://github.com/dev-rashedin/http-status-toolkit
- Owner: dev-rashedin
- License: mit
- Created: 2025-06-29T04:14:23.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-08-20T06:57:26.000Z (7 months ago)
- Last Synced: 2025-10-24T18:55:08.324Z (5 months ago)
- Topics: dx, http, status-codes, typescript
- Language: TypeScript
- Homepage:
- Size: 493 KB
- Stars: 24
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# http-status-toolkit
[](https://www.npmjs.com/package/http-status-toolkit)

[](https://github.com/dev-rashedin/http-status-toolkit/blob/main/LICENSE)
[](https://www.npmjs.com/package/http-status-toolkit)

π [View on npm](https://www.npmjs.com/package/http-status-toolkit)
A simple and lightweight toolkit for HTTP status codes and messages β written in TypeScript for safe, reliable usage.
If you like the project, please give the project a GitHub β
---
## What is this?
This package gives you:
- HTTP status codes as constants (like `StatusCodes.OK` for 200)
- Short and clear messages for each status code
- Longer, more detailed messages if you want extra info
- Localization support for 10+ languages
- A helper function (`getStatusMessage`) to fetch messages by status code
- Full TypeScript support for better coding experience
---
# π Installation Guide
You can install **http-status-toolkit** using your favorite package manager.
### Using npm
```bash
npm install http-status-toolkit
```
### Using yarn
```bash
yarn add http-status-toolkit
```
## Using pnpm
```bash
pnpm add http-status-toolkit
```
## TypeScript & Module Support
- β
Full TypeScript support with type safety and autocompletion
- β
Works in both ESM and CommonJS environments
---
## How to use
```ts
import {
StatusCodes,
getStatusMessage,
} from 'http-status-toolkit';
// Get the status code number
console.log(StatusCodes.OK); // 200
// Get a short message (default)
console.log(getStatusMessage(StatusCodes.NOT_FOUND));
// Output: "Not Found"
// Get a detailed message (import detailed messages and pass variant)
import DetailedMessages from 'http-status-toolkit/messages-detailed';
console.log(getStatusMessage(StatusCodes.NOT_FOUND, { variant: DetailedMessages }));
// Output: "Not Found: The requested resource could not be found but may be available in the future."
// Get a localized message (import a language variant)
import BengaliMessages from 'http-status-toolkit/messages-bn';
console.log(getStatusMessage(StatusCodes.NOT_FOUND, { variant: BengaliMessages }));
// Output: (Not Found message in Bengali)
```
---
## Whatβs included?
- `StatusCodes`: constants for all HTTP status codes
- `StatusMessages`: short messages for each code (English default)
- `DetailedStatusMessages`: longer, more detailed English messages
- `getStatusMessage(code, options?)`: returns the message for a status code; optionally pass a `{ variant }` to get localized or detailed messages
> **Note:**
> `getStatusMessage` returns the HTTP reason phrase for a status code.
> You can also use the alias `getReasonPhrase`, which behaves the same way.
---
## Common HTTP Status Codes
| Code | Constant | Message |
| ---- | ------------ | ---------------- |
| 200 | OK | Request OK |
| 201 | CREATED | Resource created |
| 400 | BAD_REQUEST | Bad input |
| 401 | UNAUTHORIZED | Auth required |
| 403 | FORBIDDEN | Access denied |
| 404 | NOT_FOUND | Not found |
| 500 | SERVER_ERROR | Server crashed |
π **[See full list of status codes](./docs/default-status-messages.md)**
π **[See status codes with detailed messages](./docs/detailed-status-messages.md)**
---
## Supported Languages (Localization)
You can import message variants for different languages:
| Language | Import Path | Docs File |
|-------------|-------------------------------------|-----------------------------------|
| English (default) | β | β |
| Detailed English | `messages-detailed` | [detailed-status-messages.md](./docs/detailed-status-messages.md) |
| Bengali | `messages-bn` | [bengali-status-messages.md](./docs/bengali-status-messages.md) |
| Chinese | `messages-zh` | [chinese-status-messages.md](./docs/chinese-status-messages.md) |
| Hindi | `messages-hi` | [hindi-status-messages.md](./docs/hindi-status-messages.md) |
| Arabic | `messages-ar` | [arabic-status-messages.md](./docs/arabic-status-messages.md) |
| German | `messages-de` | [german-status-messages.md](./docs/german-status-messages.md) |
| French | `messages-fr` | [french-status-messages.md](./docs/french-status-messages.md) |
| Italian | `messages-it` | [italian-status-messages.md](./docs/italian-status-messages.md) |
| Spanish | `messages-es` | [spanish-status-messages.md](./docs/spanish-status-messages.md) |
| Japanese | `messages-ja` | [japanese-status-messages.md](./docs/japanese-status-messages.md) |
| Russian | `messages-ru` | [russian-status-messages.md](./docs/russian-status-messages.md) |
---
## Contributors
Thanks to everyone who has contributed to this project! Special thanks to:
- [Rocky Haque](https://github.com/rockyhaque) β for their valuable pull request(s)
Contributions of any kind are always welcome. Feel free to open issues or submit PRs!
---
## License
MIT License. See the LICENSE file.
---
## Contributions
Feel free to suggest improvements or add new status codes by opening issues or pull requests on GitHub.
---
## Links
- **GitHub:** [https://github.com/dev-rashedin/http-status-toolkit](https://github.com/dev-rashedin/http-status-toolkit)
- **Portfolio:** [https://www.rashedin.dev](https://www.rashedin.dev)
---
Made with β€οΈ by [Rashedin Islam](https://www.rashedin.dev)