@ooneex/http-request 0.17.0 → 1.0.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 +80 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1 +1,80 @@
|
|
|
1
|
-
# @ooneex/
|
|
1
|
+
# @ooneex/http-request
|
|
2
|
+
|
|
3
|
+
HTTP request abstraction with URL parsing, query parameters, language detection, header management, and multipart file upload support.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
✅ **URL Parsing** - Automatic URL parsing with path, query parameters, and host extraction via @ooneex/url
|
|
12
|
+
|
|
13
|
+
✅ **HTTP Method Detection** - Reads and normalizes the HTTP method from the native Request object
|
|
14
|
+
|
|
15
|
+
✅ **Header Management** - Integrated HTTP header handling and user agent parsing via @ooneex/http-header
|
|
16
|
+
|
|
17
|
+
✅ **Query Parameters** - Automatic extraction of query string parameters into a typed record
|
|
18
|
+
|
|
19
|
+
✅ **Route Parameters** - Support for route parameters passed via configuration
|
|
20
|
+
|
|
21
|
+
✅ **Request Payload** - Access to parsed request body payload
|
|
22
|
+
|
|
23
|
+
✅ **File Uploads** - Multipart form data parsing with file extraction into IRequestFile instances
|
|
24
|
+
|
|
25
|
+
✅ **Language Detection** - Automatic locale detection from Accept-Language header, query params (lang/locale), or X-Custom-Lang header
|
|
26
|
+
|
|
27
|
+
✅ **Client IP** - Access to the client IP address
|
|
28
|
+
|
|
29
|
+
✅ **Type-Safe** - Full TypeScript support with generic config types for params, payload, and queries
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
bun add @ooneex/http-request
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Basic Request Handling
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { HttpRequest } from '@ooneex/http-request';
|
|
43
|
+
|
|
44
|
+
const request = new HttpRequest(nativeRequest, {
|
|
45
|
+
params: { id: '123' },
|
|
46
|
+
payload: { name: 'John' },
|
|
47
|
+
ip: '127.0.0.1',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log(request.path); // "/users/123"
|
|
51
|
+
console.log(request.method); // "GET"
|
|
52
|
+
console.log(request.host); // "example.com"
|
|
53
|
+
console.log(request.ip); // "127.0.0.1"
|
|
54
|
+
console.log(request.params); // { id: "123" }
|
|
55
|
+
console.log(request.queries); // Parsed query parameters
|
|
56
|
+
console.log(request.language); // { code: "en", region: "US" }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### File Upload Handling
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { HttpRequest } from '@ooneex/http-request';
|
|
63
|
+
|
|
64
|
+
const request = new HttpRequest(nativeRequest, {
|
|
65
|
+
form: formData,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Access uploaded files
|
|
69
|
+
for (const [key, file] of Object.entries(request.files)) {
|
|
70
|
+
console.log(key, file);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
Made with love by the Ooneex team
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/http-request",
|
|
3
|
-
"description": "HTTP request
|
|
4
|
-
"version": "0.
|
|
3
|
+
"description": "HTTP request abstraction with URL parsing, query parameters, language detection, header management, and multipart file upload support",
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"npm:publish": "bun publish --tolerate-republish --access public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ooneex/http-header": "0.
|
|
32
|
-
"@ooneex/http-request-file": "0.
|
|
33
|
-
"@ooneex/url": "0.
|
|
31
|
+
"@ooneex/http-header": "0.17.0",
|
|
32
|
+
"@ooneex/http-request-file": "0.17.0",
|
|
33
|
+
"@ooneex/url": "0.17.1",
|
|
34
34
|
"accept-language-parser": "^1.5.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@ooneex/translation": "0.0.
|
|
38
|
-
"@ooneex/types": "0.0.
|
|
37
|
+
"@ooneex/translation": "0.0.18",
|
|
38
|
+
"@ooneex/types": "0.0.19",
|
|
39
39
|
"@types/accept-language-parser": "^1.5.8"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|