File tree 3 files changed +43
-28
lines changed
3 files changed +43
-28
lines changed Original file line number Diff line number Diff line change 2
2
" @litehex/node-vault " : major
3
3
---
4
4
5
- BREAKING: The responses are wrapped in a record of type ` SafeReturn<T, VaultError> ` . This record contains the ` data ` property for successful responses and the ` error ` property for error responses.
5
+ BREAKING: The responses of commands are wrapped in a record with type of ` SafeReturn<T, VaultError> ` .
6
6
7
- This change only affects the return value of commands. Here is an example of how to use it :
7
+ This record contains two properties :
8
8
9
- ``` typescript
10
- import { VaultError , Client } from ' @litehex/node-vault ' ;
9
+ - ` data ` : The ` data ` property for successful responses. The value depends on the command.
10
+ - ` error ` : The ` error ` property for error responses. The type is ` VaultError ` , which is a subclass of ` Error ` .
11
11
12
- const { data, error } = await vc .write ({
13
- path: ' secret/test' ,
14
- data: {
15
- foo: ' bar'
16
- }
17
- });
12
+ Read [ Migration guide] ( https://github.com/shahradelahi/node-vault/wiki/Migration ) for more details on how to use it.
18
13
19
-
20
- if (error ) {
21
- if (error instanceof VaultError ) {
22
- return console .log (` Panic Mode: ${error .message } ` );
23
- }
24
- return console .log (error ); // Probably fetch failed. Should we retry?
25
- }
26
-
27
- // The error is checked by the last statement above and the only possibility is the success response with the `data` property
28
-
29
- console .log (error ); // undefined
30
- console .log (data ); // { request_id: '...', lease_id: '...', ... }
31
- ```
32
-
33
- This feature is called Atomic Responses, which means there are only two responses: ` success ` and ` error ` .
34
-
35
- Your editor/IDE might not detect any errors, so please make sure to update and verify correctness with every usage.
Original file line number Diff line number Diff line change
1
+ ## Migration to v1
2
+
3
+ ### Responses of commands
4
+
5
+ The responses of commands are wrapped in a record with type of ` SafeReturn<T, VaultError> ` .
6
+
7
+ This record contains two properties:
8
+
9
+ - ` data ` : The ` data ` property for successful responses. The value depends on the command.
10
+ - ` error ` : The ` error ` property for error responses. The type is ` VaultError ` , which is a subclass of ` Error ` .
11
+
12
+ Your editor/IDE might not detect any errors, so please make sure to update and verify correctness of every usage.
13
+
14
+ ###### Example
15
+
16
+ ``` typescript
17
+ import { VaultError , Client } from ' @litehex/node-vault' ;
18
+
19
+ const { data, error } = await vc .write ({
20
+ path: ' secret/test' ,
21
+ data: {
22
+ foo: ' bar'
23
+ }
24
+ });
25
+
26
+ if (error ) {
27
+ if (error instanceof VaultError ) {
28
+ return console .log (` Panic Mode: ${error .message } ` );
29
+ }
30
+ return console .log (error ); // Probably fetch failed. Should we retry?
31
+ }
32
+
33
+ // The error is checked by the last statement above and the only possibility is the success response with the `data` property
34
+
35
+ console .log (error ); // undefined
36
+ console .log (data ); // { request_id: '...', lease_id: '...', ... }
37
+ ```
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ console.log(deleted); // { data: true }
104
104
105
105
For complete usages, please dive into the [ Wiki] ( https://github.com/shahradelahi/node-vault/wiki ) .
106
106
107
- For all configuration options, please see [ the API docs] ( https://paka.dev/npm /@litehex/node-vault ) .
107
+ For all configuration options, please see [ the API docs] ( https://www.jsdocs.io/package /@litehex/node-vault ) .
108
108
109
109
### 🤝 Contributing
110
110
You can’t perform that action at this time.
0 commit comments