Skip to content

Commit f84623d

Browse files
committed
readme file updated
1 parent cac2588 commit f84623d

File tree

1 file changed

+54
-10
lines changed

1 file changed

+54
-10
lines changed

README.md

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# http-status-toolkit
22

3-
A small and simple toolkit for HTTP status codes and messages. Made with TypeScript for easy and safe use.
3+
A simple and lightweight toolkit for HTTP status codes and messages — written in TypeScript for safe, reliable usage.
44

55
---
66

@@ -11,7 +11,7 @@ This package gives you:
1111
- HTTP status codes as constants (like `StatusCodes.OK` for 200)
1212
- Short and clear messages for each status code
1313
- Longer, more detailed messages if you want extra info
14-
- A helper function to get messages by status code
14+
- A helper function (getStatusMessage) to fetch messages by status code
1515
- Full TypeScript support for better coding experience
1616

1717
---
@@ -22,27 +22,71 @@ Use npm or yarn to add it to your project:
2222

2323
```bash
2424
npm install http-status-toolkit
25-
or
26-
yarn add http-status-toolkit
25+
# or
26+
yarn add http-status-toolkit
27+
```
2728

2829

29-
import { StatusCodes, StatusMessages, DetailedStatusMessages, getStatusMessage } from 'http-status-toolkit';
30+
## How to use
31+
32+
```ts
33+
// Import what you need from the toolkit
34+
import {
35+
StatusCodes,
36+
StatusMessages,
37+
DetailedStatusMessages,
38+
getStatusMessage,
39+
} from 'http-status-toolkit';
3040

3141
// Get the status code number
3242
console.log(StatusCodes.OK); // 200
3343

3444
// Get a short message (default)
35-
console.log(getStatusMessage(StatusCodes.NOT_FOUND)); // "Not Found"
45+
console.log(getStatusMessage(StatusCodes.NOT_FOUND));
46+
// Output: "Not Found"
3647

3748
// 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."
49+
console.log(getStatusMessage(StatusCodes.NOT_FOUND, true));
50+
// Output: "Not Found: The requested resource could not be found but may be available in the future."
4051

4152
// You can also access messages directly
42-
console.log(StatusMessages[StatusCodes.FORBIDDEN]); // "Forbidden"
53+
console.log(StatusMessages[StatusCodes.FORBIDDEN]);
54+
// Output: "Forbidden"
55+
4356
console.log(DetailedStatusMessages[StatusCodes.FORBIDDEN]);
44-
// "Forbidden: The server understood the request but refuses to authorize it."
57+
// Output: "Forbidden: The server understood the request but refuses to authorize it."
58+
```
59+
60+
61+
62+
## What’s included?
63+
- `StatusCodes`: constants for all HTTP status codes
64+
- `StatusMessages`: short messages for each code
65+
- `DetailedStatusMessages`: longer, more detailed messages
66+
- `getStatusMessage(code, detailed?)`: returns either a short or detailed message for a given status code
67+
68+
69+
70+
## TypeScript & Module Support
71+
72+
- ✅ Full TypeScript support with type safety and autocompletion
73+
- ✅ Works in both ESM and CommonJS environments
74+
75+
Works in ESM and CommonJS
76+
77+
```ts
78+
// ESM
79+
import { StatusCodes } from 'http-status-toolkit';
80+
81+
// CommonJS
82+
const { StatusCodes } = require('http-status-toolkit');
83+
```
84+
4585

86+
## License
87+
MIT License. See the LICENSE file.
4688

89+
## Contributions
90+
Feel free to suggest improvements or add new status codes by opening issues or pull requests on GitHub.
4791

4892

0 commit comments

Comments
 (0)