You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-14Lines changed: 22 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,19 @@ Utility to interact with HTTP status codes.
6
6
7
7
## Usage
8
8
9
-
Once you require this module, you may call it with either an HTTP code or a message name. With an HTTP code, you will get the message name while with a message name you will get an HTTP code.
9
+
Once you import or require this module, you may call it with either an HTTP code or a status name. With an HTTP code, you will get the status name while with a status name you will get an HTTP code or some complementary information.
10
+
11
+
For example, `status[418]` return `IM_A_TEAPOT` while `status.IM_A_TEAPOT` return `"I'm a teapot"` and `status.IM_A_TEAPOT_CODE` returns `418`.
10
12
11
13
The package is written in TypeScript and built for CommonJS and ESM.
12
14
13
-
### HTTP Status codes
15
+
## HTTP Status codes
16
+
17
+
HTTP code names, information, and classes are respectively accessible with the property `{code}_NAME`, `{code}_MESSAGE` and `{code}_CLASS`. This includes all statuses in the [IANA HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml), with the only addition being `418 I'm a teapot`.
14
18
15
-
HTTP code names, messages, and classes are respectively accessible with the property `{code}_NAME`, `{code}_MESSAGE` and `{code}_CLASS`. This includes all statuses in the [IANA HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml), with the only addition being `418 I'm a teapot`.
19
+
## Extra codes
16
20
17
-
Extra status code are also made available that are not defined in the IANA registry, but used by popular software. They are grouped by category. Specific properties are exported by `http-status` under the property `extra` followed by the category name. Also, extra codes are merge with regular status codes and made available as modules available inside `http-status/lib/{category}`.
21
+
Extra status code are also made available that are not defined in the IANA registry, but used by popular softwares. They are grouped by category. Specific properties are exported by `http-status` under the property `extra` followed by the category name. Also, extra codes are merge with regular status codes and made available as modules available inside `http-status/lib/{category}`.
18
22
19
23
Available categories are:
20
24
@@ -29,9 +33,11 @@ Available categories are:
29
33
<dd>Cloudflare's reverse proxy service expands the 5xx error class to signal issues with the origin server.</dd>
30
34
</dl>
31
35
32
-
### HTTP Status code classes
36
+
They are accessible throught the `status.extra[category]` property. It is also possible to import one of the category with `import status from "http-status/<category>" or `const status = require("http-status/<category>")`. In the later case, all the categories properties are merge with the common HTTP statuses.
37
+
38
+
## HTTP Status code classes
33
39
34
-
In addition to HTTP status codes, this module also contains status code classes under the `classes` property. Similar to HTTP codes, you can access class names and messages with the property `{class}_NAME` and `{class}_MESSAGE`
40
+
In addition to HTTP status codes, this module also contains status code classes under the `classes` property. Similar to HTTP codes, you can access class names and messages with the property `{class}_NAME` and `{class}_MESSAGE`.
35
41
36
42
## API
37
43
@@ -95,7 +101,7 @@ For additional information, please refer to [original code](./src/index.litcoffe
This package is developed by [Adaltas](https://www.adaltas.com).
200
+
The project is sponsored by [Adaltas](https://www.adaltas.com) based in Paris, France. Adaltas offers support and consulting on distributed systems, big data and open source.
0 commit comments