@little-nebulae/http 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +354 -334
  2. package/dist/index.js +141 -121
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,9 +1,29 @@
1
1
  // src/constants/headers.ts
2
2
  const HTTP_HEADER_ENUM = {
3
3
  AUTHORIZATION: "authorization",
4
+ CACHE_CONTROL: "cache-control",
5
+ CONNECTION: "connection",
6
+ CONTENT_ENCODING: "content-encoding",
7
+ CONTENT_SECURITY_POLICY: "content-security-policy",
4
8
  CONTENT_TYPE: "content-type",
5
9
  COOKIE: "cookie",
6
- RETRY_AFTER: "retry-after"
10
+ CROSS_ORIGIN_RESOURCE_POLICY: "cross-origin-resource-policy",
11
+ DATE: "date",
12
+ ETAG: "etag",
13
+ EXPIRES: "expires",
14
+ FORWARDED: "forwarded",
15
+ HOST: "host",
16
+ KEEP_ALIVE: "keep-alive",
17
+ LAST_MODIFIED: "last-modified",
18
+ LOCATION: "location",
19
+ ORIGIN: "origin",
20
+ REFERER: "referer",
21
+ REFERRER_POLICY: "referrer-policy",
22
+ RETRY_AFTER: "retry-after",
23
+ SET_COOKIE: "set-cookie",
24
+ TRANSFER_ENCODING: "transfer-encoding",
25
+ UPGRADE: "upgrade",
26
+ USER_AGENT: "user-agent"
7
27
  };
8
28
  // src/constants/request-methods.ts
9
29
  const HTTP_REQUEST_METHOD_ENUM = {
@@ -20,167 +40,167 @@ const HTTP_REQUEST_METHOD_ENUM = {
20
40
  // src/constants/response-statuses/error/client.ts
21
41
  const HTTP_CLIENT_ERROR_RESPONSE_STATUS_ENUM = {
22
42
  BAD_REQUEST: {
23
- code: 400,
24
- text: "Bad Request"
43
+ CODE: 400,
44
+ TEXT: "Bad Request"
25
45
  },
26
46
  UNAUTHORIZED: {
27
- code: 401,
28
- text: "Unauthorized"
47
+ CODE: 401,
48
+ TEXT: "Unauthorized"
29
49
  },
30
50
  PAYMENT_REQUIRED: {
31
- code: 402,
32
- text: "Payment Required"
51
+ CODE: 402,
52
+ TEXT: "Payment Required"
33
53
  },
34
54
  FORBIDDEN: {
35
- code: 403,
36
- text: "Forbidden"
55
+ CODE: 403,
56
+ TEXT: "Forbidden"
37
57
  },
38
58
  NOT_FOUND: {
39
- code: 404,
40
- text: "Not Found"
59
+ CODE: 404,
60
+ TEXT: "Not Found"
41
61
  },
42
62
  METHOD_NOT_ALLOWED: {
43
- code: 405,
44
- text: "Method Not Allowed"
63
+ CODE: 405,
64
+ TEXT: "Method Not Allowed"
45
65
  },
46
66
  NOT_ACCEPTABLE: {
47
- code: 406,
48
- text: "Not Acceptable"
67
+ CODE: 406,
68
+ TEXT: "Not Acceptable"
49
69
  },
50
70
  PROXY_AUTHENTICATION_REQUIRED: {
51
- code: 407,
52
- text: "Proxy Authentication Required"
71
+ CODE: 407,
72
+ TEXT: "Proxy Authentication Required"
53
73
  },
54
74
  REQUEST_TIMEOUT: {
55
- code: 408,
56
- text: "Request Timeout"
75
+ CODE: 408,
76
+ TEXT: "Request Timeout"
57
77
  },
58
78
  CONFLICT: {
59
- code: 409,
60
- text: "Conflict"
79
+ CODE: 409,
80
+ TEXT: "Conflict"
61
81
  },
62
82
  GONE: {
63
- code: 410,
64
- text: "Gone"
83
+ CODE: 410,
84
+ TEXT: "Gone"
65
85
  },
66
86
  LENGTH_REQUIRED: {
67
- code: 411,
68
- text: "Length Required"
87
+ CODE: 411,
88
+ TEXT: "Length Required"
69
89
  },
70
90
  PRECONDITION_FAILED: {
71
- code: 412,
72
- text: "Precondition Failed"
91
+ CODE: 412,
92
+ TEXT: "Precondition Failed"
73
93
  },
74
94
  CONTENT_TOO_LARGE: {
75
- code: 413,
76
- text: "Content Too Large"
95
+ CODE: 413,
96
+ TEXT: "Content Too Large"
77
97
  },
78
98
  URI_TOO_LONG: {
79
- code: 414,
80
- text: "URI Too Long"
99
+ CODE: 414,
100
+ TEXT: "URI Too Long"
81
101
  },
82
102
  UNSUPPORTED_MEDIA_TYPE: {
83
- code: 415,
84
- text: "Unsupported Media Type"
103
+ CODE: 415,
104
+ TEXT: "Unsupported Media Type"
85
105
  },
86
106
  RANGE_NOT_SATISFIABLE: {
87
- code: 416,
88
- text: "Range Not Satisfiable"
107
+ CODE: 416,
108
+ TEXT: "Range Not Satisfiable"
89
109
  },
90
110
  EXPECTATION_FAILED: {
91
- code: 417,
92
- text: "Expectation Failed"
111
+ CODE: 417,
112
+ TEXT: "Expectation Failed"
93
113
  },
94
114
  IM_A_TEAPOT: {
95
- code: 418,
96
- text: "I'm a teapot"
115
+ CODE: 418,
116
+ TEXT: "I'm a teapot"
97
117
  },
98
118
  MISDIRECTED_REQUEST: {
99
- code: 421,
100
- text: "Misdirected Request"
119
+ CODE: 421,
120
+ TEXT: "Misdirected Request"
101
121
  },
102
122
  UNPROCESSABLE_CONTENT: {
103
- code: 422,
104
- text: "Unprocessable Content"
123
+ CODE: 422,
124
+ TEXT: "Unprocessable Content"
105
125
  },
106
126
  LOCKED: {
107
- code: 423,
108
- text: "Locked"
127
+ CODE: 423,
128
+ TEXT: "Locked"
109
129
  },
110
130
  FAILED_DEPENDENCY: {
111
- code: 424,
112
- text: "Failed Dependency"
131
+ CODE: 424,
132
+ TEXT: "Failed Dependency"
113
133
  },
114
134
  TOO_EARLY: {
115
- code: 425,
116
- text: "Too Early"
135
+ CODE: 425,
136
+ TEXT: "Too Early"
117
137
  },
118
138
  UPGRADE_REQUIRED: {
119
- code: 426,
120
- text: "Upgrade Required"
139
+ CODE: 426,
140
+ TEXT: "Upgrade Required"
121
141
  },
122
142
  PRECONDITION_REQUIRED: {
123
- code: 428,
124
- text: "Precondition Required"
143
+ CODE: 428,
144
+ TEXT: "Precondition Required"
125
145
  },
126
146
  TOO_MANY_REQUESTS: {
127
- code: 429,
128
- text: "Too Many Requests"
147
+ CODE: 429,
148
+ TEXT: "Too Many Requests"
129
149
  },
130
150
  REQUEST_HEADER_FIELDS_TOO_LARGE: {
131
- code: 431,
132
- text: "Request Header Fields Too Large"
151
+ CODE: 431,
152
+ TEXT: "Request Header Fields Too Large"
133
153
  },
134
154
  UNAVAILABLE_FOR_LEGAL_REASONS: {
135
- code: 451,
136
- text: "Unavailable For Legal Reasons"
155
+ CODE: 451,
156
+ TEXT: "Unavailable For Legal Reasons"
137
157
  }
138
158
  };
139
159
  // src/constants/response-statuses/error/server.ts
140
160
  const HTTP_SERVER_ERROR_RESPONSE_STATUS_ENUM = {
141
161
  INTERNAL_SERVER_ERROR: {
142
- code: 500,
143
- text: "Internal Server Error"
162
+ CODE: 500,
163
+ TEXT: "Internal Server Error"
144
164
  },
145
165
  NOT_IMPLEMENTED: {
146
- code: 501,
147
- text: "Not Implemented"
166
+ CODE: 501,
167
+ TEXT: "Not Implemented"
148
168
  },
149
169
  BAD_GATEWAY: {
150
- code: 502,
151
- text: "Bad Gateway"
170
+ CODE: 502,
171
+ TEXT: "Bad Gateway"
152
172
  },
153
173
  SERVICE_UNAVAILABLE: {
154
- code: 503,
155
- text: "Service Unavailable"
174
+ CODE: 503,
175
+ TEXT: "Service Unavailable"
156
176
  },
157
177
  GATEWAY_TIMEOUT: {
158
- code: 504,
159
- text: "Gateway Timeout"
178
+ CODE: 504,
179
+ TEXT: "Gateway Timeout"
160
180
  },
161
181
  HTTP_VERSION_NOT_SUPPORTED: {
162
- code: 505,
163
- text: "HTTP Version Not Supported"
182
+ CODE: 505,
183
+ TEXT: "HTTP Version Not Supported"
164
184
  },
165
185
  VARIANT_ALSO_NEGOTIATES: {
166
- code: 506,
167
- text: "Variant Also Negotiates"
186
+ CODE: 506,
187
+ TEXT: "Variant Also Negotiates"
168
188
  },
169
189
  INSUFFICIENT_STORAGE: {
170
- code: 507,
171
- text: "Insufficient Storage"
190
+ CODE: 507,
191
+ TEXT: "Insufficient Storage"
172
192
  },
173
193
  LOOP_DETECTED: {
174
- code: 508,
175
- text: "Loop Detected"
194
+ CODE: 508,
195
+ TEXT: "Loop Detected"
176
196
  },
177
197
  NOT_EXTENDED: {
178
- code: 510,
179
- text: "Not Extended"
198
+ CODE: 510,
199
+ TEXT: "Not Extended"
180
200
  },
181
201
  NETWORK_AUTHENTICATION_REQUIRED: {
182
- code: 511,
183
- text: "Network Authentication Required"
202
+ CODE: 511,
203
+ TEXT: "Network Authentication Required"
184
204
  }
185
205
  };
186
206
  // src/constants/response-statuses/error/index.ts
@@ -191,90 +211,90 @@ const HTTP_ERROR_RESPONSE_STATUS_ENUM = {
191
211
  // src/constants/response-statuses/information.ts
192
212
  const HTTP_INFORMATIONAL_RESPONSE_STATUS_ENUM = {
193
213
  CONTINUE: {
194
- code: 100,
195
- text: "Continue"
214
+ CODE: 100,
215
+ TEXT: "Continue"
196
216
  },
197
217
  SWITCHING_PROTOCOLS: {
198
- code: 101,
199
- text: "Switching Protocols"
218
+ CODE: 101,
219
+ TEXT: "Switching Protocols"
200
220
  },
201
221
  EARLY_HINTS: {
202
- code: 103,
203
- text: "Early Hints"
222
+ CODE: 103,
223
+ TEXT: "Early Hints"
204
224
  }
205
225
  };
206
226
  // src/constants/response-statuses/redirection.ts
207
227
  const HTTP_REDIRECTION_RESPONSE_STATUS_ENUM = {
208
228
  MULTIPLE_CHOICES: {
209
- code: 300,
210
- text: "Multiple Choices"
229
+ CODE: 300,
230
+ TEXT: "Multiple Choices"
211
231
  },
212
232
  MOVED_PERMANENTLY: {
213
- code: 301,
214
- text: "Moved Permanently"
233
+ CODE: 301,
234
+ TEXT: "Moved Permanently"
215
235
  },
216
236
  FOUND: {
217
- code: 302,
218
- text: "Found"
237
+ CODE: 302,
238
+ TEXT: "Found"
219
239
  },
220
240
  SEE_OTHER: {
221
- code: 303,
222
- text: "See Other"
241
+ CODE: 303,
242
+ TEXT: "See Other"
223
243
  },
224
244
  NOT_MODIFIED: {
225
- code: 304,
226
- text: "Not Modified"
245
+ CODE: 304,
246
+ TEXT: "Not Modified"
227
247
  },
228
248
  TEMPORARY_REDIRECT: {
229
- code: 307,
230
- text: "Temporary Redirect"
249
+ CODE: 307,
250
+ TEXT: "Temporary Redirect"
231
251
  },
232
252
  PERMANENT_REDIRECT: {
233
- code: 308,
234
- text: "Permanent Redirect"
253
+ CODE: 308,
254
+ TEXT: "Permanent Redirect"
235
255
  }
236
256
  };
237
257
  // src/constants/response-statuses/success.ts
238
258
  const HTTP_SUCCESSFUL_RESPONSE_STATUS_ENUM = {
239
259
  OK: {
240
- code: 200,
241
- text: "OK"
260
+ CODE: 200,
261
+ TEXT: "OK"
242
262
  },
243
263
  CREATED: {
244
- code: 201,
245
- text: "Created"
264
+ CODE: 201,
265
+ TEXT: "Created"
246
266
  },
247
267
  ACCEPTED: {
248
- code: 202,
249
- text: "Accepted"
268
+ CODE: 202,
269
+ TEXT: "Accepted"
250
270
  },
251
271
  NON_AUTHORITATIVE_INFORMATION: {
252
- code: 203,
253
- text: "Non-Authoritative Information"
272
+ CODE: 203,
273
+ TEXT: "Non-Authoritative Information"
254
274
  },
255
275
  NO_CONTENT: {
256
- code: 204,
257
- text: "No Content"
276
+ CODE: 204,
277
+ TEXT: "No Content"
258
278
  },
259
279
  RESET_CONTENT: {
260
- code: 205,
261
- text: "Reset Content"
280
+ CODE: 205,
281
+ TEXT: "Reset Content"
262
282
  },
263
283
  PARTIAL_CONTENT: {
264
- code: 206,
265
- text: "Partial Content"
284
+ CODE: 206,
285
+ TEXT: "Partial Content"
266
286
  },
267
287
  MULTI_STATUS: {
268
- code: 207,
269
- text: "Multi-Status"
288
+ CODE: 207,
289
+ TEXT: "Multi-Status"
270
290
  },
271
291
  ALREADY_REPORTED: {
272
- code: 208,
273
- text: "Already Reported"
292
+ CODE: 208,
293
+ TEXT: "Already Reported"
274
294
  },
275
295
  IM_USED: {
276
- code: 226,
277
- text: "IM Used"
296
+ CODE: 226,
297
+ TEXT: "IM Used"
278
298
  }
279
299
  };
280
300
  // src/constants/response-statuses/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@little-nebulae/http",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"