@kinevolution/appwrite-functions-shared-utils 0.1.16 → 0.1.17

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/dist/utils.d.ts CHANGED
@@ -75,5 +75,5 @@ export type Response<T> = {
75
75
  success: false;
76
76
  error: string;
77
77
  };
78
- export declare const formatResponse: <T>(res: any, response: Response<T>) => any;
78
+ export declare const formatResponse: <T>(res: any, response: Response<T>, error?: (message: string) => void) => any;
79
79
  export {};
package/dist/utils.js CHANGED
@@ -116,6 +116,8 @@ function validateRequestBody(bodyJson, fields) {
116
116
  data: validatedData,
117
117
  };
118
118
  }
119
- export const formatResponse = (res, response) => {
119
+ export const formatResponse = (res, response, error) => {
120
+ if (!response.success && error)
121
+ error(response.error);
120
122
  return res.json(response, response.success ? 200 : 500);
121
123
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.16",
6
+ "version": "0.1.17",
7
7
  "license": "ISC",
8
8
  "author": "Nicolas Forêt <nicolas4@gmail.com>",
9
9
  "description": "Shared utilities for Appwrite functions",