@qnx/client 0.7.10 → 0.7.12
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 +41 -27
- package/dist/client.iife.js +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@qnx/client`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@qnx/client` provides utility classes and types to help standardize and simplify handling of API responses on the client side. It supports typed access to data, messages, and errors from server responses.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## ✨ Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- Typed wrappers for API responses
|
|
8
|
+
- Easy parsing of both success and error responses
|
|
9
|
+
- Works well with any REST API response structure
|
|
10
|
+
- Improves code readability and error handling consistency
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
npm install @qnx/client
|
|
11
|
-
```
|
|
12
|
+
## 📦 Installation
|
|
12
13
|
|
|
13
|
-
You can
|
|
14
|
+
You can install via your preferred package manager:
|
|
14
15
|
|
|
15
16
|
```bash
|
|
17
|
+
# npm
|
|
18
|
+
npm install @qnx/client
|
|
19
|
+
|
|
20
|
+
# yarn
|
|
16
21
|
yarn add @qnx/client
|
|
17
|
-
```
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
# pnpm
|
|
20
24
|
pnpm install @qnx/client
|
|
21
25
|
```
|
|
22
26
|
|
|
23
|
-
## Usage
|
|
27
|
+
## 🚀 Usage
|
|
28
|
+
|
|
29
|
+
### General API Response
|
|
24
30
|
|
|
25
|
-
```
|
|
31
|
+
```ts
|
|
26
32
|
import { ApiResponse } from '@qnx/client'
|
|
27
33
|
|
|
28
34
|
const res = {
|
|
@@ -49,7 +55,9 @@ const error = apiRes.getError()
|
|
|
49
55
|
const errorCode = apiRes.getErrorCode()
|
|
50
56
|
```
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
### Success Response
|
|
59
|
+
|
|
60
|
+
```ts
|
|
53
61
|
import { ApiSuccessResponse } from '@qnx/client'
|
|
54
62
|
|
|
55
63
|
const res = {
|
|
@@ -63,7 +71,9 @@ const data = apiRes.getData()
|
|
|
63
71
|
const message = apiRes.getMessage()
|
|
64
72
|
```
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
### Error Response
|
|
75
|
+
|
|
76
|
+
```ts
|
|
67
77
|
import { ApiErrorResponse } from '@qnx/client'
|
|
68
78
|
|
|
69
79
|
const res = {
|
|
@@ -82,8 +92,11 @@ const error = apiRes.getError()
|
|
|
82
92
|
const errorCode = apiRes.getErrorCode()
|
|
83
93
|
```
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
### Types
|
|
96
|
+
|
|
97
|
+
#### ApiResponseValue
|
|
98
|
+
|
|
99
|
+
```ts
|
|
87
100
|
import type { ApiResponseValue } from '@qnx/client'
|
|
88
101
|
|
|
89
102
|
const response: ApiResponseValue<number> = {
|
|
@@ -102,8 +115,9 @@ const response: ApiResponseValue<number> = {
|
|
|
102
115
|
}
|
|
103
116
|
```
|
|
104
117
|
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
#### ApiSuccessResponseValue
|
|
119
|
+
|
|
120
|
+
```ts
|
|
107
121
|
import type { ApiSuccessResponseValue } from '@qnx/client'
|
|
108
122
|
|
|
109
123
|
const successResponse: ApiSuccessResponseValue<number> = {
|
|
@@ -112,8 +126,9 @@ const successResponse: ApiSuccessResponseValue<number> = {
|
|
|
112
126
|
}
|
|
113
127
|
```
|
|
114
128
|
|
|
115
|
-
|
|
116
|
-
|
|
129
|
+
#### ApiErrorResponseValue
|
|
130
|
+
|
|
131
|
+
```ts
|
|
117
132
|
import type { ApiErrorResponseValue } from '@qnx/client'
|
|
118
133
|
|
|
119
134
|
const errorResponse: ApiErrorResponseValue = {
|
|
@@ -126,13 +141,12 @@ const errorResponse: ApiErrorResponseValue = {
|
|
|
126
141
|
}
|
|
127
142
|
```
|
|
128
143
|
|
|
129
|
-
## Contributing
|
|
130
|
-
|
|
131
|
-
Pull requests are welcome. For major changes, please open an issue first
|
|
132
|
-
to discuss what you would like to change.
|
|
144
|
+
## 🤝 Contributing
|
|
133
145
|
|
|
134
|
-
|
|
146
|
+
Pull requests are welcome!
|
|
147
|
+
For major changes, please open an issue first to discuss your proposed updates.
|
|
148
|
+
Ensure tests are updated for any feature changes.
|
|
135
149
|
|
|
136
|
-
## License
|
|
150
|
+
## 📄 License
|
|
137
151
|
|
|
138
|
-
[MIT License](https://github.com/yatendra121/client/blob/main/LICENSE.md) © 2023
|
|
152
|
+
[MIT License](https://github.com/yatendra121/client/blob/main/LICENSE.md) © 2023–PRESENT [Yatendra Kushwaha](https://github.com/yatendra121)
|
package/dist/client.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var client=function(r){"use strict";class t{constructor(e={}){this.response=e}getErrorCode(){return this.response.errorCode}getErrors(){return this.response.errors}getError(){return this.response.error}getMessage(){return this.response.message}getData(){return this.response.data}}class o{constructor(e){this.response=e}getData(){return this.response.data}getMessage(){return this.response.message}}class n{constructor(e){this.response=e}getError(){return this.response.error}getErrors(){return this.response.errors}getErrorCode(){return this.response.errorCode}}return r.ApiErrorResponse=n,r.ApiResponse=t,r.ApiSuccessResponse=o,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),r}({});
|
|
1
|
+
var client=(function(r){"use strict";class t{constructor(e={}){this.response=e}getErrorCode(){return this.response.errorCode}getErrors(){return this.response.errors}getError(){return this.response.error}getMessage(){return this.response.message}getData(){return this.response.data}}class o{constructor(e){this.response=e}getData(){return this.response.data}getMessage(){return this.response.message}}class n{constructor(e){this.response=e}getError(){return this.response.error}getErrors(){return this.response.errors}getErrorCode(){return this.response.errorCode}}return r.ApiErrorResponse=n,r.ApiResponse=t,r.ApiSuccessResponse=o,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),r})({});
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@qnx/client",
|
|
3
3
|
"description": "@qnx/client for handling response",
|
|
4
4
|
"author": "Yatendra Kushwaha <https://github.com/yatendra121>",
|
|
5
|
-
"version": "0.7.
|
|
5
|
+
"version": "0.7.12",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/yatendra121",
|
|
8
8
|
"homepage": "https://github.com/yatendra121/qnx/tree/main/packages/client",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@qnx/client",
|
|
3
3
|
"description": "@qnx/client for handling response",
|
|
4
4
|
"author": "Yatendra Kushwaha <https://github.com/yatendra121>",
|
|
5
|
-
"version": "0.7.
|
|
5
|
+
"version": "0.7.12",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/yatendra121",
|
|
8
8
|
"homepage": "https://github.com/yatendra121/qnx/tree/main/packages/client",
|