@dev-coindcx/network 1.0.3-test → 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.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @dev-coindcx/network
2
+
3
+ Lightweight HTTP helpers built on [axios](https://github.com/axios/axios): a configurable `AxiosServiceClass` and an `ApiServiceProWrapper` that delegates to any `ApiServiceInterface` implementation.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @dev-coindcx/network
9
+ ```
10
+
11
+ Peer consumers should use a compatible axios major; this package pins axios for consistent installs.
12
+
13
+ ## Exports
14
+
15
+ | Export | Description |
16
+ | ---------------------- | --------------------------------------------------------------------------- |
17
+ | `AxiosServiceClass` | Creates an axios instance with optional timeout and HTTP verb helpers. |
18
+ | `ApiServiceProWrapper` | Wraps an `ApiServiceInterface` (e.g. for layering or swapping backends). |
19
+
20
+ ## `AxiosServiceClass`
21
+
22
+ Construct with optional `ApiServiceOptions` (`timeout` in ms, default `30000`). Use standard axios request config on each call.
23
+
24
+ ```ts
25
+ import { AxiosServiceClass } from '@dev-coindcx/network';
26
+
27
+ const api = new AxiosServiceClass({ timeout: 15000 });
28
+
29
+ // GET
30
+ const users = await api.get('https://api.example.com/users', {
31
+ params: { page: 1 },
32
+ });
33
+
34
+ // POST — put the body in `data`
35
+ const created = await api.post('https://api.example.com/users', {
36
+ data: { name: 'Ada' },
37
+ headers: { 'Content-Type': 'application/json' },
38
+ });
39
+
40
+ // PATCH / PUT — same pattern: `data` for body
41
+ await api.patch('https://api.example.com/users/1', {
42
+ data: { name: 'Grace' },
43
+ });
44
+
45
+ // DELETE
46
+ await api.delete('https://api.example.com/users/1', {});
47
+ ```
48
+
49
+ Access the underlying axios instance (e.g. for interceptors or defaults):
50
+
51
+ ```ts
52
+ const client = api.getInstance();
53
+ client.defaults.headers.common['Authorization'] = 'Bearer …';
54
+ ```
55
+
56
+ ## `ApiServiceProWrapper`
57
+
58
+ Wraps any object that implements `ApiServiceInterface` and forwards `get`, `post`, `patch`, `put`, `delete`, and `getInstance`.
59
+
60
+ ```ts
61
+ import { AxiosServiceClass, ApiServiceProWrapper } from '@dev-coindcx/network';
62
+
63
+ const inner = new AxiosServiceClass();
64
+ const api = new ApiServiceProWrapper(inner);
65
+
66
+ const res = await api.get('https://api.example.com/health', {});
67
+ ```
68
+
69
+ ## Types
70
+
71
+ Relevant shapes match axios where possible:
72
+
73
+ - `ApiServiceOptions` — `{ timeout?: number }`
74
+ - `ApiServiceConfig` — extends axios `AxiosRequestConfig`
75
+ - `ApiServiceResponse` — extends axios `AxiosResponse`
76
+
77
+ ## Build (contributors)
78
+
79
+ From this package directory:
80
+
81
+ ```bash
82
+ npm run build
83
+ ```
84
+
85
+ Output is emitted to `dist/` (`index.js`, `index.cjs`, and declaration files).
@@ -1,12 +1,12 @@
1
- import { AxiosInstance } from 'axios';
2
- import { ApiServiceInterface, ApiServiceConfig, ApiServiceResponse, ApiServiceOptions } from '../utils/api.interface';
1
+ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import { ApiServiceInterface, ApiServiceOptions } from '../utils/api.interface';
3
3
  export declare class AxiosServiceClass implements ApiServiceInterface {
4
4
  private axiosInstance;
5
5
  constructor(options?: ApiServiceOptions);
6
- get(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
7
- post(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
8
- patch(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
9
- put(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
10
- delete(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
6
+ get(url: string, config: AxiosRequestConfig): Promise<AxiosResponse>;
7
+ post(url: string, config: AxiosRequestConfig): Promise<AxiosResponse>;
8
+ patch(url: string, config: AxiosRequestConfig): Promise<AxiosResponse>;
9
+ put(url: string, config: AxiosRequestConfig): Promise<AxiosResponse>;
10
+ delete(url: string, config: AxiosRequestConfig): Promise<AxiosResponse>;
11
11
  getInstance(): AxiosInstance;
12
12
  }
@@ -1,4 +1,4 @@
1
- import { AxiosRequestConfig, AxiosResponse } from "axios";
1
+ import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
2
  export interface ApiServiceInterface {
3
3
  get(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
4
4
  post(url: string, config: ApiServiceConfig): Promise<ApiServiceResponse>;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@dev-coindcx/network",
3
- "version": "1.0.3-test",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "description": "A networking library for seamless API calls and efficient data handling",
6
6
  "type": "module",
7
7
  "files": [
8
- "dist"
8
+ "dist",
9
+ "README.md"
9
10
  ],
10
11
  "main": "./dist/index.cjs",
11
12
  "module": "./dist/index.js",
@@ -22,6 +23,6 @@
22
23
  },
23
24
  "author": "Manushivam Maheshwari",
24
25
  "dependencies": {
25
- "axios": "^1.7.4"
26
+ "axios": "1.7.4"
26
27
  }
27
28
  }