@one-format/http-plugin 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -3
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +70 -0
- package/dist/types.js.map +1 -0
- package/package.json +22 -6
- package/src/index.ts +39 -0
- package/src/types.ts +151 -0
- package/tsconfig.json +37 -0
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @one-format/http-plugin
|
|
2
|
+
|
|
3
|
+
An official one-format plugin for formatting standard HTTP status codes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @one-format/http-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The package exports a plugin object containing two tools:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import httpPlugin from "@one-format/http-plugin";
|
|
17
|
+
|
|
18
|
+
httpPlugin.tools.codeToMessage(404);
|
|
19
|
+
// "Not Found"
|
|
20
|
+
|
|
21
|
+
httpPlugin.tools.codeToFormal(404);
|
|
22
|
+
// "HTTP/404 Not Found"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Use the plugin with `@one-format/core` to expose its tools directly:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import adapter from "@one-format/core";
|
|
29
|
+
import httpPlugin from "@one-format/http-plugin";
|
|
30
|
+
|
|
31
|
+
const http = adapter(httpPlugin);
|
|
32
|
+
|
|
33
|
+
http.codeToMessage(500); // "Internal Server Error"
|
|
34
|
+
http.codeToFormal(201); // "HTTP/201 Created"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Supported status codes
|
|
38
|
+
|
|
39
|
+
The `HttpStatusCode` type covers the standard HTTP status codes in the
|
|
40
|
+
informational (1xx), success (2xx), redirection (3xx), client error (4xx),
|
|
41
|
+
and server error (5xx) ranges, including WebDAV and other registered codes.
|
|
42
|
+
TypeScript will restrict tool inputs to the supported codes.
|
|
43
|
+
|
|
44
|
+
### API
|
|
45
|
+
|
|
46
|
+
- `tools.codeToMessage(code)` - returns the reason phrase for a status code.
|
|
47
|
+
- `tools.codeToFormal(code)` - returns a formatted `HTTP/<code> <message>`
|
|
48
|
+
status line.
|
|
49
|
+
- `metadata` - identifies the plugin and its version.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
EUPL-1.2
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type HttpStatusCode } from "./types.js";
|
|
2
|
+
type PluginFn<Input = any, Output = any> = (input: Input) => Output;
|
|
3
|
+
interface PluginMetadata {
|
|
4
|
+
name: string;
|
|
5
|
+
author: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
}
|
|
8
|
+
interface PluginType<Tools extends Record<string, any>> {
|
|
9
|
+
metadata: PluginMetadata;
|
|
10
|
+
tools: {
|
|
11
|
+
[K in keyof Tools]: PluginFn<Tools[K]['input'], Tools[K]['output']>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare const httpPlugin: PluginType<{
|
|
15
|
+
codeToFormal: {
|
|
16
|
+
input: HttpStatusCode;
|
|
17
|
+
output: `HTTP/${HttpStatusCode} ${string}`;
|
|
18
|
+
};
|
|
19
|
+
codeToMessage: {
|
|
20
|
+
input: HttpStatusCode;
|
|
21
|
+
output: string;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
export default httpPlugin;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEvE,KAAK,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAEpE,UAAU,cAAc;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,UAAU,UAAU,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAClD,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE;SACF,CAAC,IAAI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;KACtE,CAAC;CACL;AAGD,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC;IACzB,YAAY,EAAE;QACN,KAAK,EAAE,cAAc,CAAC;QACtB,MAAM,EAAE,QAAQ,cAAc,IAAI,MAAM,EAAE,CAAA;KACjD,CAAC;IACF,aAAa,EAAE;QACX,KAAK,EAAE,cAAc,CAAC;QACtB,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;CACA,CAUJ,CAAA;eAEc,UAAU"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HTTP_STATUS_MESSAGES } from "./types.js";
|
|
2
|
+
const httpPlugin = {
|
|
3
|
+
"metadata": {
|
|
4
|
+
"author": "Vedansh Shetti <vedansh.shetti@gmail.com> - one-format Official Plugin",
|
|
5
|
+
"name": "One-Format Datetime",
|
|
6
|
+
"version": "1.1.0"
|
|
7
|
+
},
|
|
8
|
+
tools: {
|
|
9
|
+
codeToFormal: (code) => `HTTP/${code} ${HTTP_STATUS_MESSAGES[code]}`,
|
|
10
|
+
codeToMessage: (code) => HTTP_STATUS_MESSAGES[code]
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default httpPlugin;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AAiBvE,MAAM,UAAU,GASP;IACL,UAAU,EAAE;QACR,QAAQ,EAAE,wEAAwE;QAClF,MAAM,EAAE,qBAAqB;QAC7B,SAAS,EAAE,OAAO;KACrB;IACD,KAAK,EAAE;QACH,YAAY,EAAE,CAAC,IAAoB,EAAE,EAAE,CAAC,QAAQ,IAAI,IAAI,oBAAoB,CAAC,IAAI,CAAC,EAAE;QACpF,aAAa,EAAE,CAAC,IAAoB,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC;KACtE;CACJ,CAAA;AAED,eAAe,UAAU,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard HTTP Status Codes as defined by IANA and RFC 9110.
|
|
3
|
+
*/
|
|
4
|
+
export type HttpStatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
5
|
+
export declare const HTTP_STATUS_MESSAGES: Record<HttpStatusCode, string>;
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAEtB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GAGH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GAGH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GAGH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GAGH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAIR,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAwEtD,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const HTTP_STATUS_MESSAGES = {
|
|
2
|
+
// 1xx: Informational
|
|
3
|
+
100: 'Continue',
|
|
4
|
+
101: 'Switching Protocols',
|
|
5
|
+
102: 'Processing',
|
|
6
|
+
103: 'Early Hints',
|
|
7
|
+
// 2xx: Success
|
|
8
|
+
200: 'OK',
|
|
9
|
+
201: 'Created',
|
|
10
|
+
202: 'Accepted',
|
|
11
|
+
203: 'Non-Authoritative Information',
|
|
12
|
+
204: 'No Content',
|
|
13
|
+
205: 'Reset Content',
|
|
14
|
+
206: 'Partial Content',
|
|
15
|
+
207: 'Multi-Status',
|
|
16
|
+
208: 'Already Reported',
|
|
17
|
+
226: 'IM Used',
|
|
18
|
+
// 3xx: Redirection
|
|
19
|
+
300: 'Multiple Choices',
|
|
20
|
+
301: 'Moved Permanently',
|
|
21
|
+
302: 'Found',
|
|
22
|
+
303: 'See Other',
|
|
23
|
+
304: 'Not Modified',
|
|
24
|
+
305: 'Use Proxy',
|
|
25
|
+
307: 'Temporary Redirect',
|
|
26
|
+
308: 'Permanent Redirect',
|
|
27
|
+
// 4xx: Client Error
|
|
28
|
+
400: 'Bad Request',
|
|
29
|
+
401: 'Unauthorized',
|
|
30
|
+
402: 'Payment Required',
|
|
31
|
+
403: 'Forbidden',
|
|
32
|
+
404: 'Not Found',
|
|
33
|
+
405: 'Method Not Allowed',
|
|
34
|
+
406: 'Not Acceptable',
|
|
35
|
+
407: 'Proxy Authentication Required',
|
|
36
|
+
408: 'Request Timeout',
|
|
37
|
+
409: 'Conflict',
|
|
38
|
+
410: 'Gone',
|
|
39
|
+
411: 'Length Required',
|
|
40
|
+
412: 'Precondition Failed',
|
|
41
|
+
413: 'Payload Too Large',
|
|
42
|
+
414: 'URI Too Long',
|
|
43
|
+
415: 'Unsupported Media Type',
|
|
44
|
+
416: 'Range Not Satisfiable',
|
|
45
|
+
417: 'Expectation Failed',
|
|
46
|
+
418: "I'm a teapot",
|
|
47
|
+
421: 'Misdirected Request',
|
|
48
|
+
422: 'Unprocessable Entity',
|
|
49
|
+
423: 'Locked',
|
|
50
|
+
424: 'Failed Dependency',
|
|
51
|
+
425: 'Too Early',
|
|
52
|
+
426: 'Upgrade Required',
|
|
53
|
+
428: 'Precondition Required',
|
|
54
|
+
429: 'Too Many Requests',
|
|
55
|
+
431: 'Request Header Fields Too Large',
|
|
56
|
+
451: 'Unavailable For Legal Reasons',
|
|
57
|
+
// 5xx: Server Error
|
|
58
|
+
500: 'Internal Server Error',
|
|
59
|
+
501: 'Not Implemented',
|
|
60
|
+
502: 'Bad Gateway',
|
|
61
|
+
503: 'Service Unavailable',
|
|
62
|
+
504: 'Gateway Timeout',
|
|
63
|
+
505: 'HTTP Version Not Supported',
|
|
64
|
+
506: 'Variant Also Negotiates',
|
|
65
|
+
507: 'Insufficient Storage',
|
|
66
|
+
508: 'Loop Detected',
|
|
67
|
+
510: 'Not Extended',
|
|
68
|
+
511: 'Network Authentication Required',
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8EA,MAAM,CAAC,MAAM,oBAAoB,GAAmC;IAClE,qBAAqB;IACrB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,aAAa;IAElB,eAAe;IACf,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,SAAS;IAEd,mBAAmB;IACnB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,oBAAoB;IAEzB,oBAAoB;IACpB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,wBAAwB;IAC7B,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,iCAAiC;IACtC,GAAG,EAAE,+BAA+B;IAEpC,oBAAoB;IACpB,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,4BAA4B;IACjC,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,iCAAiC;CAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@one-format/http-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@one-format/http-plugin",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"http-formatting"
|
|
7
|
+
],
|
|
8
|
+
"license": "EUPL-1.2",
|
|
9
|
+
"author": "Vedansh Shetti <vedansh.shetti@gmail.com>",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"I didnt feel like writing tests, its just more code to maintain\"",
|
|
14
|
+
"prepublishOnly": "tsc",
|
|
15
|
+
"postpublish": "rimraf dist"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^26.6.5",
|
|
19
|
+
"rimraf": "^6.1.3",
|
|
20
|
+
"typescript": "^7.0.2"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HTTP_STATUS_MESSAGES, type HttpStatusCode } from "./types.js";
|
|
2
|
+
|
|
3
|
+
type PluginFn<Input = any, Output = any> = (input: Input) => Output;
|
|
4
|
+
|
|
5
|
+
interface PluginMetadata {
|
|
6
|
+
name: string; // Plugin Name
|
|
7
|
+
author: string; // Author
|
|
8
|
+
version?: string; // Version Number, preferably SemVer.
|
|
9
|
+
}
|
|
10
|
+
interface PluginType<Tools extends Record<string, any>> {
|
|
11
|
+
metadata: PluginMetadata;
|
|
12
|
+
tools: {
|
|
13
|
+
[K in keyof Tools]: PluginFn<Tools[K]['input'], Tools[K]['output']>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const httpPlugin: PluginType<{
|
|
19
|
+
codeToFormal: {
|
|
20
|
+
input: HttpStatusCode,
|
|
21
|
+
output: `HTTP/${HttpStatusCode} ${string}`
|
|
22
|
+
},
|
|
23
|
+
codeToMessage: {
|
|
24
|
+
input: HttpStatusCode,
|
|
25
|
+
output: string
|
|
26
|
+
}
|
|
27
|
+
}> = {
|
|
28
|
+
"metadata": {
|
|
29
|
+
"author": "Vedansh Shetti <vedansh.shetti@gmail.com> - one-format Official Plugin",
|
|
30
|
+
"name": "One-Format Datetime",
|
|
31
|
+
"version": "1.1.0"
|
|
32
|
+
},
|
|
33
|
+
tools: {
|
|
34
|
+
codeToFormal: (code: HttpStatusCode) => `HTTP/${code} ${HTTP_STATUS_MESSAGES[code]}`,
|
|
35
|
+
codeToMessage: (code: HttpStatusCode) => HTTP_STATUS_MESSAGES[code]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default httpPlugin;
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard HTTP Status Codes as defined by IANA and RFC 9110.
|
|
3
|
+
*/
|
|
4
|
+
export type HttpStatusCode =
|
|
5
|
+
// 1xx: Informational
|
|
6
|
+
| 100 // Continue
|
|
7
|
+
| 101 // Switching Protocols
|
|
8
|
+
| 102 // Processing (WebDAV)
|
|
9
|
+
| 103 // Early Hints
|
|
10
|
+
|
|
11
|
+
// 2xx: Success
|
|
12
|
+
| 200 // OK
|
|
13
|
+
| 201 // Created
|
|
14
|
+
| 202 // Accepted
|
|
15
|
+
| 203 // Non-Authoritative Information
|
|
16
|
+
| 204 // No Content
|
|
17
|
+
| 205 // Reset Content
|
|
18
|
+
| 206 // Partial Content
|
|
19
|
+
| 207 // Multi-Status (WebDAV)
|
|
20
|
+
| 208 // Already Reported (WebDAV)
|
|
21
|
+
| 226 // IM Used
|
|
22
|
+
|
|
23
|
+
// 3xx: Redirection
|
|
24
|
+
| 300 // Multiple Choices
|
|
25
|
+
| 301 // Moved Permanently
|
|
26
|
+
| 302 // Found
|
|
27
|
+
| 303 // See Other
|
|
28
|
+
| 304 // Not Modified
|
|
29
|
+
| 305 // Use Proxy
|
|
30
|
+
| 307 // Temporary Redirect
|
|
31
|
+
| 308 // Permanent Redirect
|
|
32
|
+
|
|
33
|
+
// 4xx: Client Error
|
|
34
|
+
| 400 // Bad Request
|
|
35
|
+
| 401 // Unauthorized
|
|
36
|
+
| 402 // Payment Required
|
|
37
|
+
| 403 // Forbidden
|
|
38
|
+
| 404 // Not Found
|
|
39
|
+
| 405 // Method Not Allowed
|
|
40
|
+
| 406 // Not Acceptable
|
|
41
|
+
| 407 // Proxy Authentication Required
|
|
42
|
+
| 408 // Request Timeout
|
|
43
|
+
| 409 // Conflict
|
|
44
|
+
| 410 // Gone
|
|
45
|
+
| 411 // Length Required
|
|
46
|
+
| 412 // Precondition Failed
|
|
47
|
+
| 413 // Payload Too Large
|
|
48
|
+
| 414 // URI Too Long
|
|
49
|
+
| 415 // Unsupported Media Type
|
|
50
|
+
| 416 // Range Not Satisfiable
|
|
51
|
+
| 417 // Expectation Failed
|
|
52
|
+
| 418 // I'm a teapot (RFC 2324)
|
|
53
|
+
| 421 // Misdirected Request
|
|
54
|
+
| 422 // Unprocessable Entity (WebDAV)
|
|
55
|
+
| 423 // Locked (WebDAV)
|
|
56
|
+
| 424 // Failed Dependency (WebDAV)
|
|
57
|
+
| 425 // Too Early
|
|
58
|
+
| 426 // Upgrade Required
|
|
59
|
+
| 428 // Precondition Required
|
|
60
|
+
| 429 // Too Many Requests
|
|
61
|
+
| 431 // Request Header Fields Too Large
|
|
62
|
+
| 451 // Unavailable For Legal Reasons
|
|
63
|
+
|
|
64
|
+
// 5xx: Server Error
|
|
65
|
+
| 500 // Internal Server Error
|
|
66
|
+
| 501 // Not Implemented
|
|
67
|
+
| 502 // Bad Gateway
|
|
68
|
+
| 503 // Service Unavailable
|
|
69
|
+
| 504 // Gateway Timeout
|
|
70
|
+
| 505 // HTTP Version Not Supported
|
|
71
|
+
| 506 // Variant Also Negotiates
|
|
72
|
+
| 507 // Insufficient Storage (WebDAV)
|
|
73
|
+
| 508 // Loop Detected (WebDAV)
|
|
74
|
+
| 510 // Not Extended
|
|
75
|
+
| 511; // Network Authentication Required
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export const HTTP_STATUS_MESSAGES: Record<HttpStatusCode, string> = {
|
|
80
|
+
// 1xx: Informational
|
|
81
|
+
100: 'Continue',
|
|
82
|
+
101: 'Switching Protocols',
|
|
83
|
+
102: 'Processing',
|
|
84
|
+
103: 'Early Hints',
|
|
85
|
+
|
|
86
|
+
// 2xx: Success
|
|
87
|
+
200: 'OK',
|
|
88
|
+
201: 'Created',
|
|
89
|
+
202: 'Accepted',
|
|
90
|
+
203: 'Non-Authoritative Information',
|
|
91
|
+
204: 'No Content',
|
|
92
|
+
205: 'Reset Content',
|
|
93
|
+
206: 'Partial Content',
|
|
94
|
+
207: 'Multi-Status',
|
|
95
|
+
208: 'Already Reported',
|
|
96
|
+
226: 'IM Used',
|
|
97
|
+
|
|
98
|
+
// 3xx: Redirection
|
|
99
|
+
300: 'Multiple Choices',
|
|
100
|
+
301: 'Moved Permanently',
|
|
101
|
+
302: 'Found',
|
|
102
|
+
303: 'See Other',
|
|
103
|
+
304: 'Not Modified',
|
|
104
|
+
305: 'Use Proxy',
|
|
105
|
+
307: 'Temporary Redirect',
|
|
106
|
+
308: 'Permanent Redirect',
|
|
107
|
+
|
|
108
|
+
// 4xx: Client Error
|
|
109
|
+
400: 'Bad Request',
|
|
110
|
+
401: 'Unauthorized',
|
|
111
|
+
402: 'Payment Required',
|
|
112
|
+
403: 'Forbidden',
|
|
113
|
+
404: 'Not Found',
|
|
114
|
+
405: 'Method Not Allowed',
|
|
115
|
+
406: 'Not Acceptable',
|
|
116
|
+
407: 'Proxy Authentication Required',
|
|
117
|
+
408: 'Request Timeout',
|
|
118
|
+
409: 'Conflict',
|
|
119
|
+
410: 'Gone',
|
|
120
|
+
411: 'Length Required',
|
|
121
|
+
412: 'Precondition Failed',
|
|
122
|
+
413: 'Payload Too Large',
|
|
123
|
+
414: 'URI Too Long',
|
|
124
|
+
415: 'Unsupported Media Type',
|
|
125
|
+
416: 'Range Not Satisfiable',
|
|
126
|
+
417: 'Expectation Failed',
|
|
127
|
+
418: "I'm a teapot",
|
|
128
|
+
421: 'Misdirected Request',
|
|
129
|
+
422: 'Unprocessable Entity',
|
|
130
|
+
423: 'Locked',
|
|
131
|
+
424: 'Failed Dependency',
|
|
132
|
+
425: 'Too Early',
|
|
133
|
+
426: 'Upgrade Required',
|
|
134
|
+
428: 'Precondition Required',
|
|
135
|
+
429: 'Too Many Requests',
|
|
136
|
+
431: 'Request Header Fields Too Large',
|
|
137
|
+
451: 'Unavailable For Legal Reasons',
|
|
138
|
+
|
|
139
|
+
// 5xx: Server Error
|
|
140
|
+
500: 'Internal Server Error',
|
|
141
|
+
501: 'Not Implemented',
|
|
142
|
+
502: 'Bad Gateway',
|
|
143
|
+
503: 'Service Unavailable',
|
|
144
|
+
504: 'Gateway Timeout',
|
|
145
|
+
505: 'HTTP Version Not Supported',
|
|
146
|
+
506: 'Variant Also Negotiates',
|
|
147
|
+
507: 'Insufficient Storage',
|
|
148
|
+
508: 'Loop Detected',
|
|
149
|
+
510: 'Not Extended',
|
|
150
|
+
511: 'Network Authentication Required',
|
|
151
|
+
} as const;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment Settings
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"target": "esnext",
|
|
6
|
+
"lib": ["esnext"],
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
|
|
9
|
+
// Output Layout
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
|
|
16
|
+
// Stricter Typechecking
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUncheckedIndexedAccess": true,
|
|
19
|
+
"exactOptionalPropertyTypes": true,
|
|
20
|
+
"noImplicitReturns": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
"noUnusedLocals": true,
|
|
23
|
+
"noUnusedParameters": true,
|
|
24
|
+
"noFallthroughCasesInSwitch": true,
|
|
25
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
26
|
+
|
|
27
|
+
// Module & Syntax
|
|
28
|
+
"verbatimModuleSyntax": true,
|
|
29
|
+
"isolatedModules": true,
|
|
30
|
+
"moduleDetection": "force",
|
|
31
|
+
"skipLibCheck": true,
|
|
32
|
+
"esModuleInterop": true,
|
|
33
|
+
"forceConsistentCasingInFileNames": true
|
|
34
|
+
},
|
|
35
|
+
"include": ["src/**/*"],
|
|
36
|
+
"exclude": ["node_modules", "dist"]
|
|
37
|
+
}
|