auravia-connect 1.0.2 β†’ 1.0.3

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 +270 -15
  2. package/package.json +1 -1
package/Readme.md CHANGED
@@ -1,28 +1,283 @@
1
1
  # auravia-connect
2
2
 
3
- πŸš€ Smart frontend–backend connector with built-in mocking, fallback, and debug timeline.
3
+ πŸš€ Smart frontend–backend connector with built-in mocking, fallback, and auto-mocking.
4
4
 
5
- Auravia Connect is a lightweight HTTP client designed to simplify communication between frontend and backend while providing powerful developer tools like smart mocking and automatic fallback.
5
+ Auravia Connect is a lightweight HTTP client that keeps your frontend moving β€” even when your backend isn’t ready.
6
6
 
7
7
  ---
8
8
 
9
- ## ✨ Features
9
+ ## ✨ Why auravia-connect?
10
10
 
11
- - πŸ”— Simple HTTP client (GET, POST, PUT, PATCH, DELETE)
12
- - 🧠 Smart mock generator
13
- - πŸ§ͺ Wildcard route mocking (`/users/:id`)
14
- - ⏱ Mock delay simulation
15
- - 🚨 Error simulation
16
- - πŸ”„ Smart fallback when network fails
17
- - 🧩 Request & response interceptors
18
- - 🧭 Debug timeline
19
- - βš™οΈ Strategy control (prefer mock or network)
20
- - πŸ“¦ Zero dependencies
21
- - ⚑ Lightweight
11
+ Most tools only send requests.
12
+ Auravia goes further:
13
+
14
+ * πŸ”— Simple HTTP client
15
+ * πŸ§ͺ Built-in mocking
16
+ * πŸ”„ Smart fallback when network fails
17
+ * ⚑ Auto mock when backend is unavailable
18
+ * 🧩 Request & response interceptors
19
+ * 🧭 Debug timeline
20
+ * πŸ“¦ Zero dependencies
21
+ * ⚑ Lightweight
22
+
23
+ πŸ‘‰ **Your UI keeps working β€” even when your backend doesn’t.**
22
24
 
23
25
  ---
24
26
 
25
27
  ## πŸ“¦ Installation
26
28
 
27
29
  ```bash
28
- npm install auravia-connect
30
+ npm install auravia-connect
31
+ ```
32
+
33
+ ---
34
+
35
+ ## πŸš€ Quick Start
36
+
37
+ ```js
38
+ const { createClient } = require("auravia-connect");
39
+
40
+ const api = createClient({
41
+ baseURL: "https://api.example.com"
42
+ });
43
+
44
+ async function run() {
45
+ const res = await api.get("/users");
46
+ console.log(res.data);
47
+ }
48
+
49
+ run();
50
+ ```
51
+
52
+ ---
53
+
54
+ ## πŸ§ͺ Manual Mocking
55
+
56
+ Use manual mocks when you want full control over fake data.
57
+
58
+ ```js
59
+ const api = createClient({
60
+ mock: true,
61
+ debug: true
62
+ });
63
+
64
+ api.mock("/users", {
65
+ id: "number",
66
+ name: "text"
67
+ }, { count: 3 });
68
+
69
+ const res = await api.get("/users");
70
+ console.log(res.data);
71
+ ```
72
+
73
+ βœ… Works without a backend.
74
+
75
+ ---
76
+
77
+ ## 🎯 Wildcard Routes
78
+
79
+ Auravia supports dynamic routes.
80
+
81
+ ```js
82
+ api.mock("/users/:id", {
83
+ id: "number",
84
+ name: "text"
85
+ });
86
+
87
+ await api.get("/users/42");
88
+ ```
89
+
90
+ ---
91
+
92
+ ## πŸ”„ Smart Fallback
93
+
94
+ Automatically return mock when network fails.
95
+
96
+ ```js
97
+ const api = createClient({
98
+ baseURL: "http://localhost:5000",
99
+ mock: true,
100
+ mockFallback: true,
101
+ debug: true
102
+ });
103
+ ```
104
+
105
+ **Flow**
106
+
107
+ ```
108
+ network fails β†’ fallback mock used
109
+ ```
110
+
111
+ ---
112
+
113
+ ## ⚑ Auto Mock Mode (⭐ Standout Feature)
114
+
115
+ Auravia can generate smart fake data automatically β€” no manual mocks needed.
116
+
117
+ ```js
118
+ const api = createClient({
119
+ autoMock: true,
120
+ debug: true
121
+ });
122
+
123
+ const res = await api.get("/users");
124
+ console.log(res.data);
125
+ ```
126
+
127
+ **Example output**
128
+
129
+ ```js
130
+ {
131
+ id: 123,
132
+ name: "Sample text",
133
+ active: true
134
+ }
135
+ ```
136
+
137
+ ### When AutoMock runs
138
+
139
+ AutoMock triggers when:
140
+
141
+ * ❌ no manual mock exists
142
+ * ❌ network request fails
143
+ * βœ… `autoMock: true` is enabled
144
+
145
+ ---
146
+
147
+ ## βš™οΈ Mock Strategy
148
+
149
+ Control whether to prefer mock or network.
150
+
151
+ ### Prefer mock (default)
152
+
153
+ ```js
154
+ createClient({
155
+ mock: true,
156
+ mockStrategy: "prefer-mock"
157
+ });
158
+ ```
159
+
160
+ **Flow**
161
+
162
+ ```
163
+ mock exists β†’ return immediately
164
+ ```
165
+
166
+ ---
167
+
168
+ ### Prefer network first
169
+
170
+ ```js
171
+ createClient({
172
+ mock: true,
173
+ mockFallback: true,
174
+ mockStrategy: "prefer-network"
175
+ });
176
+ ```
177
+
178
+ **Flow**
179
+
180
+ ```
181
+ try network β†’ if fails β†’ fallback mock
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 🧩 Interceptors
187
+
188
+ ### Request interceptor
189
+
190
+ ```js
191
+ api.onRequest((config) => {
192
+ config.headers.Authorization = "Bearer token";
193
+ return config;
194
+ });
195
+ ```
196
+
197
+ ### Response interceptor
198
+
199
+ ```js
200
+ api.onResponse((response) => {
201
+ if (!response.ok) {
202
+ console.error("API Error:", response.error);
203
+ }
204
+ return response;
205
+ });
206
+ ```
207
+
208
+ ---
209
+
210
+ ## 🧭 Debug Timeline
211
+
212
+ Enable detailed request logs.
213
+
214
+ ```js
215
+ const api = createClient({
216
+ debug: true
217
+ });
218
+ ```
219
+
220
+ **Example output**
221
+
222
+ ```
223
+ [auravia] β†’ GET /users
224
+ [auravia] … trying network
225
+ [auravia] ⚑ auto mock generated
226
+ [auravia] ⏱ 42ms
227
+ ```
228
+
229
+ ---
230
+
231
+ ## πŸ“š API Reference
232
+
233
+ ### createClient(config)
234
+
235
+ Creates a new client instance.
236
+
237
+ | Option | Type | Description |
238
+ | ------------ | ------- | ------------------------------------- |
239
+ | baseURL | string | Base API URL |
240
+ | headers | object | Default headers |
241
+ | timeout | number | Request timeout (ms) |
242
+ | mock | boolean | Enable manual mocks |
243
+ | mockFallback | boolean | Enable fallback to mock |
244
+ | autoMock | boolean | Enable automatic mock generation |
245
+ | debug | boolean | Enable debug logs |
246
+ | mockStrategy | string | `"prefer-mock"` or `"prefer-network"` |
247
+
248
+ ---
249
+
250
+ ### api.mock(url, response, options)
251
+
252
+ Register a manual mock.
253
+
254
+ **Built-in generators**
255
+
256
+ * `"text"`
257
+ * `"number"`
258
+ * `"boolean"`
259
+ * `"uuid"`
260
+ * `"image"`
261
+ * `"video"`
262
+ * `"mp3"`
263
+
264
+ **Example**
265
+
266
+ ```js
267
+ api.mock("/profile", {
268
+ id: "number",
269
+ avatar: "image"
270
+ });
271
+ ```
272
+
273
+ -
274
+
275
+ ## 🀝 Contributing
276
+
277
+ Issues and PRs are welcome.
278
+
279
+ ---
280
+
281
+ ## πŸ“„ License
282
+
283
+ MIT Β© Dinesh R
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auravia-connect",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Smart frontend-backend connector with built-in mocking and fallback",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",