@kinevolution/appwrite-functions-shared-utils 0.1.14 → 0.1.15
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/appwrite.js +2 -0
- package/dist/utils.js +19 -25
- package/package.json +1 -1
package/dist/appwrite.js
CHANGED
package/dist/utils.js
CHANGED
|
@@ -21,32 +21,26 @@ export function validateInput(config, req) {
|
|
|
21
21
|
error: `Invalid request method: expected ${config.method}, received ${req.method}`,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
error: `Validation error: ${validation.error}`,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
24
|
+
if (!req.bodyJson) {
|
|
25
|
+
return {
|
|
26
|
+
valid: false,
|
|
27
|
+
error: 'No body provided in the request',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Validate the request body
|
|
31
|
+
const validation = validateRequestBody(req.bodyJson, config.fields);
|
|
32
|
+
if (validation.valid) {
|
|
33
|
+
return {
|
|
34
|
+
valid: true,
|
|
35
|
+
data: validation.data,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return {
|
|
40
|
+
valid: false,
|
|
41
|
+
error: `Validation error: ${validation.error}`,
|
|
42
|
+
};
|
|
46
43
|
}
|
|
47
|
-
return {
|
|
48
|
-
valid: true,
|
|
49
|
-
};
|
|
50
44
|
}
|
|
51
45
|
/**
|
|
52
46
|
* Validates and parses the JSON body of the request
|