Skip to content

Commit cac2588

Browse files
committed
readme file updated
1 parent 6dc9851 commit cac2588

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# http-status-toolkit
2+
3+
A small and simple toolkit for HTTP status codes and messages. Made with TypeScript for easy and safe use.
4+
5+
---
6+
7+
## What is this?
8+
9+
This package gives you:
10+
11+
- HTTP status codes as constants (like `StatusCodes.OK` for 200)
12+
- Short and clear messages for each status code
13+
- Longer, more detailed messages if you want extra info
14+
- A helper function to get messages by status code
15+
- Full TypeScript support for better coding experience
16+
17+
---
18+
19+
## How to install
20+
21+
Use npm or yarn to add it to your project:
22+
23+
```bash
24+
npm install http-status-toolkit
25+
or
26+
yarn add http-status-toolkit
27+
28+
29+
import { StatusCodes, StatusMessages, DetailedStatusMessages, getStatusMessage } from 'http-status-toolkit';
30+
31+
// Get the status code number
32+
console.log(StatusCodes.OK); // 200
33+
34+
// Get a short message (default)
35+
console.log(getStatusMessage(StatusCodes.NOT_FOUND)); // "Not Found"
36+
37+
// Get a detailed message
38+
console.log(getStatusMessage(StatusCodes.NOT_FOUND, true));
39+
// "Not Found: The requested resource could not be found but may be available in the future."
40+
41+
// You can also access messages directly
42+
console.log(StatusMessages[StatusCodes.FORBIDDEN]); // "Forbidden"
43+
console.log(DetailedStatusMessages[StatusCodes.FORBIDDEN]);
44+
// "Forbidden: The server understood the request but refuses to authorize it."
45+
46+
47+
48+

0 commit comments

Comments
 (0)