@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 CHANGED
@@ -28,7 +28,7 @@ export class Cowboy {
28
28
  */
29
29
  settings = {
30
30
  pathTidy(path) {
31
- return path.replace(/^\/api\/\w+\//, '/');
31
+ return path.replace(/^\/api\/\w+/, '/');
32
32
  },
33
33
  };
34
34
 
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) this.body = 'ok'; // Set body payload if we don't already have one
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
 
@@ -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.options('/', (req, res) => {
15
- return res.sendStatus(200);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momsfriendlydevco/cowboy",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Wrapper around Cloudflare Wrangler to provide a more Express-like experience",
5
5
  "scripts": {
6
6
  "lint": "eslint ."