aziosxjs 0.1.3 → 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 (2) hide show
  1. package/README.md +119 -25
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  A lightweight HTTP client for Node.js inspired by Axios.
4
4
 
5
- Aziosxjs provides a simple and clean API for making HTTP requests while keeping the internal architecture modular and extensible.
5
+ Aziosxjs provides a clean and minimal API for making HTTP requests while exposing the internal request pipeline architecture. It is built using Node.js low-level `http` and `https` modules to demonstrate how modern HTTP client libraries work internally.
6
6
 
7
- This project was built to explore how HTTP client libraries like Axios work internally, including request pipelines, interceptors, and adapter-based networking.
7
+ This project focuses on simplicity, extensibility, and educational value while still providing practical features.
8
8
 
9
9
  ---
10
10
 
@@ -13,17 +13,19 @@ This project was built to explore how HTTP client libraries like Axios work inte
13
13
  * Simple and clean API
14
14
  * Promise-based HTTP requests
15
15
  * Built using low-level Node.js `http` and `https` modules
16
- * Interceptor system for request/response manipulation
16
+ * Request and response interceptors
17
+ * Structured error system
18
+ * Request cancellation support
19
+ * Query parameter serialization
20
+ * Automatic JSON parsing
17
21
  * TypeScript support
18
- * Modular architecture for future extensions
22
+ * Modular architecture
19
23
 
20
24
  ---
21
25
 
22
26
  ## Installation
23
27
 
24
- Install the package using npm:
25
-
26
- ```
28
+ ```bash
27
29
  npm install aziosxjs
28
30
  ```
29
31
 
@@ -47,9 +49,9 @@ getUsers();
47
49
 
48
50
  ---
49
51
 
50
- ## Basic Usage
52
+ # Basic Usage
51
53
 
52
- ### GET Request
54
+ ## GET Request
53
55
 
54
56
  ```javascript
55
57
  const res = await azios.get("https://api.example.com/users");
@@ -59,7 +61,7 @@ console.log(res.data);
59
61
 
60
62
  ---
61
63
 
62
- ### POST Request
64
+ ## POST Request
63
65
 
64
66
  ```javascript
65
67
  const res = await azios.post(
@@ -75,22 +77,49 @@ console.log(res.data);
75
77
 
76
78
  ---
77
79
 
78
- ## Interceptors
80
+ # Query Parameters
81
+
82
+ Azios automatically serializes query parameters.
83
+
84
+ ```javascript
85
+ const res = await azios.get(
86
+ "https://jsonplaceholder.typicode.com/posts",
87
+ {
88
+ params: { _limit: 2 }
89
+ }
90
+ );
91
+
92
+ console.log(res.data);
93
+ ```
94
+
95
+ Generated URL:
96
+
97
+ ```
98
+ /posts?_limit=2
99
+ ```
100
+
101
+ ---
102
+
103
+ # Interceptors
79
104
 
80
105
  Interceptors allow you to modify requests or responses globally.
81
106
 
82
- ### Request Interceptor
107
+ ## Request Interceptor
83
108
 
84
109
  ```javascript
85
110
  azios.interceptors.request.use(config => {
86
111
  console.log("Request intercepted");
112
+
113
+ if (!config.headers) config.headers = {};
114
+ config.headers["x-test"] = "azios";
115
+
87
116
  return config;
88
117
  });
89
118
  ```
90
119
 
91
120
  ---
92
121
 
93
- ### Response Interceptor
122
+ ## Response Interceptor
94
123
 
95
124
  ```javascript
96
125
  azios.interceptors.response.use(response => {
@@ -101,9 +130,49 @@ azios.interceptors.response.use(response => {
101
130
 
102
131
  ---
103
132
 
104
- ## Architecture Overview
133
+ # Request Cancellation
105
134
 
106
- Aziosxjs follows a modular architecture:
135
+ Azios supports request cancellation using `AbortController`.
136
+
137
+ ```javascript
138
+ const controller = new AbortController();
139
+
140
+ azios.get(
141
+ "https://jsonplaceholder.typicode.com/users",
142
+ { signal: controller.signal }
143
+ );
144
+
145
+ controller.abort();
146
+ ```
147
+
148
+ When aborted, Azios throws a structured error with code:
149
+
150
+ ```
151
+ ABORTED
152
+ ```
153
+
154
+ ---
155
+
156
+ # Error Handling
157
+
158
+ Azios returns standardized error objects.
159
+
160
+ ```javascript
161
+ try {
162
+ await azios.get("https://wrong-url.test");
163
+ } catch (error) {
164
+ console.log(error.name); // AziosError
165
+ console.log(error.code); // NETWORK_ERROR
166
+ }
167
+ ```
168
+
169
+ Structured errors make debugging easier.
170
+
171
+ ---
172
+
173
+ # Architecture Overview
174
+
175
+ Azios follows a modular request pipeline.
107
176
 
108
177
  ```
109
178
  User Code
@@ -123,7 +192,7 @@ Return Response
123
192
 
124
193
  ---
125
194
 
126
- ## Project Structure
195
+ # Project Structure
127
196
 
128
197
  ```
129
198
  src
@@ -138,6 +207,9 @@ src
138
207
  ├── errors
139
208
  │ └── AziosError.ts
140
209
 
210
+ ├── helpers
211
+ │ └── buildURL.ts
212
+
141
213
  ├── types
142
214
  │ ├── config.ts
143
215
  │ ├── request.ts
@@ -148,31 +220,53 @@ src
148
220
 
149
221
  ---
150
222
 
151
- ## Roadmap
223
+ # Version Roadmap
224
+
225
+ ## v0.1
226
+
227
+ * Core HTTP client
228
+ * Instances
229
+ * JSON handling
230
+ * Basic request configuration
231
+
232
+ ## v0.2
233
+
234
+ * Interceptor pipeline
235
+ * Structured error system
236
+ * Request cancellation
237
+ * Query parameter serializer
238
+
239
+ ## Upcoming
152
240
 
153
241
  Future improvements planned:
154
242
 
155
- * Interceptor execution pipeline
156
- * Automatic JSON parsing
157
- * Retry strategy
243
+ * Retry mechanism
158
244
  * Request deduplication
159
- * Caching layer
245
+ * Built-in caching
246
+ * Rate limiting
160
247
  * Plugin system
248
+ * Middleware ecosystem
161
249
 
162
250
  ---
163
251
 
164
- ## Contributing
252
+ # Contributing
253
+
254
+ Contributions are welcome.
255
+
256
+ If you'd like to improve Aziosxjs:
165
257
 
166
- Contributions are welcome. Feel free to open issues or submit pull requests.
258
+ 1. Fork the repository
259
+ 2. Create a feature branch
260
+ 3. Submit a pull request
167
261
 
168
262
  ---
169
263
 
170
- ## Author
264
+ # Author
171
265
 
172
266
  Azeem Ali
173
267
 
174
268
  ---
175
269
 
176
- ## License
270
+ # License
177
271
 
178
272
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aziosxjs",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "description": "Lightweight HTTP client inspired by axios",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",