@apiquest/plugin-http 1.0.2 → 1.0.4
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 +154 -0
- package/dist/index.js +3167 -2953
- package/dist/index.js.map +1 -1
- package/esbuild.config.js +34 -34
- package/package.json +67 -62
- package/rollup.config.js +31 -31
- package/src/index.ts +420 -420
- package/tsconfig.json +20 -20
- package/tsconfig.test.json +5 -5
- package/vitest.config.ts +12 -12
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.d.ts.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# @apiquest/plugin-http
|
|
2
|
+
|
|
3
|
+
HTTP/REST protocol plugin for ApiQuest. Provides comprehensive HTTP request execution with support for all standard methods, headers, body types, SSL/TLS, proxies, and cookie management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using npm
|
|
9
|
+
npm install -g @apiquest/plugin-http
|
|
10
|
+
|
|
11
|
+
# Or using fracture CLI
|
|
12
|
+
fracture plugin install http
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Note:** This plugin is required for HTTP/REST API testing with `@apiquest/fracture`.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- All HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, etc.)
|
|
20
|
+
- Request body formats: JSON, form-data, urlencoded, raw
|
|
21
|
+
- Custom headers and query parameters
|
|
22
|
+
- Cookie jar with persistence
|
|
23
|
+
- SSL/TLS client certificates
|
|
24
|
+
- Proxy support (HTTP/HTTPS)
|
|
25
|
+
- Redirect handling
|
|
26
|
+
- Timeout configuration
|
|
27
|
+
- Authentication integration (via `@apiquest/plugin-auth`)
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Set the collection protocol to `http`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"$schema": "https://apiquest.net/schemas/collection-v1.0.json",
|
|
36
|
+
"protocol": "http",
|
|
37
|
+
"items": [
|
|
38
|
+
{
|
|
39
|
+
"type": "request",
|
|
40
|
+
"id": "get-users",
|
|
41
|
+
"name": "Get Users",
|
|
42
|
+
"data": {
|
|
43
|
+
"method": "GET",
|
|
44
|
+
"url": "https://api.example.com/users",
|
|
45
|
+
"headers": {
|
|
46
|
+
"Accept": "application/json"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### POST with JSON Body
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"type": "request",
|
|
59
|
+
"id": "create-user",
|
|
60
|
+
"name": "Create User",
|
|
61
|
+
"data": {
|
|
62
|
+
"method": "POST",
|
|
63
|
+
"url": "https://api.example.com/users",
|
|
64
|
+
"headers": {
|
|
65
|
+
"Content-Type": "application/json"
|
|
66
|
+
},
|
|
67
|
+
"body": {
|
|
68
|
+
"mode": "raw",
|
|
69
|
+
"raw": "{\"name\": \"John Doe\", \"email\": \"john@example.com\"}"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Form Data
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"data": {
|
|
80
|
+
"method": "POST",
|
|
81
|
+
"url": "https://api.example.com/upload",
|
|
82
|
+
"body": {
|
|
83
|
+
"mode": "formdata",
|
|
84
|
+
"formdata": [
|
|
85
|
+
{ "key": "file", "value": "@/path/to/file.txt", "type": "file" },
|
|
86
|
+
{ "key": "description", "value": "Test upload" }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Runtime Options
|
|
94
|
+
|
|
95
|
+
Configure SSL, proxy, redirects, and timeouts:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"options": {
|
|
100
|
+
"timeout": 30000,
|
|
101
|
+
"followRedirects": true,
|
|
102
|
+
"maxRedirects": 5,
|
|
103
|
+
"ssl": {
|
|
104
|
+
"cert": "/path/to/client-cert.pem",
|
|
105
|
+
"key": "/path/to/client-key.pem",
|
|
106
|
+
"ca": "/path/to/ca-cert.pem",
|
|
107
|
+
"passphrase": "{{certPassword}}"
|
|
108
|
+
},
|
|
109
|
+
"proxy": {
|
|
110
|
+
"url": "http://proxy.example.com:8080",
|
|
111
|
+
"auth": {
|
|
112
|
+
"username": "{{proxyUser}}",
|
|
113
|
+
"password": "{{proxyPass}}"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Response Handling
|
|
121
|
+
|
|
122
|
+
Access response data in post-request scripts:
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
quest.test('Status is 200', () => {
|
|
126
|
+
expect(quest.response.status).to.equal(200);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
quest.test('Response is JSON', () => {
|
|
130
|
+
const body = quest.response.json();
|
|
131
|
+
expect(body).to.be.an('object');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
quest.test('Has required fields', () => {
|
|
135
|
+
const body = quest.response.json();
|
|
136
|
+
expect(body).to.have.property('id');
|
|
137
|
+
expect(body).to.have.property('name');
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Compatibility
|
|
142
|
+
|
|
143
|
+
- **Authentication:** Works with `@apiquest/plugin-auth` for Bearer, Basic, OAuth2, API Key
|
|
144
|
+
- **Protocols:** HTTP/1.1, HTTP/2 (auto-negotiated)
|
|
145
|
+
- **Node.js:** Requires Node.js 20+
|
|
146
|
+
|
|
147
|
+
## Documentation
|
|
148
|
+
|
|
149
|
+
- [Fracture Documentation](https://apiquest.net/docs/fracture)
|
|
150
|
+
- [Schema Reference](https://apiquest.net/schemas/collection-v1.0.json)
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
Dual-licensed under AGPL-3.0-or-later and commercial license. See [LICENSE](./LICENSE.txt) for details.
|