@odatnurd/cf-requests 0.1.1 → 0.1.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/README.md +3 -1
- package/lib/handlers.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,11 +84,13 @@ export const $post = routeHandler(
|
|
|
84
84
|
export function success(ctx, message, result, status) {}
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Indicate a successful return in JSON with the given `HTTP` status code
|
|
87
|
+
Indicate a successful return in JSON with the given `HTTP` status code; the
|
|
88
|
+
status code is used to construct the JSON as well as the response:
|
|
88
89
|
|
|
89
90
|
```js
|
|
90
91
|
{
|
|
91
92
|
"success": true,
|
|
93
|
+
status,
|
|
92
94
|
message,
|
|
93
95
|
data: result
|
|
94
96
|
}
|
package/lib/handlers.js
CHANGED
|
@@ -16,7 +16,7 @@ export const success = (ctx, message, result, status) => {
|
|
|
16
16
|
result ??= [];
|
|
17
17
|
|
|
18
18
|
ctx.status(status);
|
|
19
|
-
return ctx.json({ success: true, message, data: result });
|
|
19
|
+
return ctx.json({ success: true, status, message, data: result });
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
|
|
@@ -31,7 +31,7 @@ export const fail = (ctx, message, status, result) => {
|
|
|
31
31
|
status ??= 400;
|
|
32
32
|
|
|
33
33
|
ctx.status(status);
|
|
34
|
-
return ctx.json({ success: false, message, data: result });
|
|
34
|
+
return ctx.json({ success: false, status, message, data: result });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
|
package/package.json
CHANGED