@momsfriendlydevco/cowboy 1.0.2 → 1.0.3
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/lib/cowboy.js +1 -1
- package/lib/response.js +5 -1
- package/middleware/cors.js +6 -3
- package/package.json +1 -1
package/lib/cowboy.js
CHANGED
package/lib/response.js
CHANGED
|
@@ -66,7 +66,11 @@ export default class CowboyResponse {
|
|
|
66
66
|
*/
|
|
67
67
|
status(code) {
|
|
68
68
|
this.code = code;
|
|
69
|
-
if (!this.body)
|
|
69
|
+
if (!this.body)
|
|
70
|
+
this.body = this.code >= 200 && this.code <= 299
|
|
71
|
+
? 'ok' // Set body payload if we don't already have one
|
|
72
|
+
: `${this.code}: Fail`
|
|
73
|
+
|
|
70
74
|
return this;
|
|
71
75
|
}
|
|
72
76
|
|
package/middleware/cors.js
CHANGED
|
@@ -11,8 +11,11 @@ export default function CowboyMiddlewareCORS(headers) {
|
|
|
11
11
|
res.set(injectHeaders);
|
|
12
12
|
|
|
13
13
|
// Handle hits to OPTIONS '/' endpoint
|
|
14
|
-
req.router.
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (!req.router.loadedCors) {
|
|
15
|
+
req.router.options('/', (req, res) => {
|
|
16
|
+
return res.sendStatus(200);
|
|
17
|
+
});
|
|
18
|
+
req.router.loadedCors = true; // Mark we've already done this so we don't keep tweaking the router
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
}
|