@thepassle/app-tools 0.8.1 → 0.8.2
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/api/index.js +4 -1
- package/api/plugins/delay.js +1 -1
- package/api/types.d.ts +1 -1
- package/dialog/types.d.ts +1 -1
- package/package.json +1 -1
package/api/index.js
CHANGED
|
@@ -111,7 +111,10 @@ export class Api {
|
|
|
111
111
|
.then(async res => {
|
|
112
112
|
for(const plugin of plugins) {
|
|
113
113
|
try {
|
|
114
|
-
|
|
114
|
+
const afterFetchResult = await plugin?.afterFetch?.(res) ?? res;
|
|
115
|
+
if(afterFetchResult) {
|
|
116
|
+
res = afterFetchResult;
|
|
117
|
+
}
|
|
115
118
|
} catch(e) {
|
|
116
119
|
log(`Plugin "${plugin.name}" error on afterFetch hook`)
|
|
117
120
|
throw e;
|
package/api/plugins/delay.js
CHANGED
package/api/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type Method = 'GET'|'DELETE'|'HEAD'|'OPTIONS'|'POST'|'PUT'|'PATCH';
|
|
|
13
13
|
|
|
14
14
|
export interface Plugin {
|
|
15
15
|
beforeFetch?: (meta: MetaParams) => MetaParams | Promise<MetaParams> | void;
|
|
16
|
-
afterFetch?: (res: Response) => Response | Promise<Response>;
|
|
16
|
+
afterFetch?: (res: Response) => void | Promise<void> | Response | Promise<Response>;
|
|
17
17
|
transform?: (data: any) => any;
|
|
18
18
|
name: string;
|
|
19
19
|
handleError?: (e: Error) => boolean;
|
package/dialog/types.d.ts
CHANGED