two-stroke 1.0.32 → 1.0.34

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +20 -7
package/package.json CHANGED
@@ -51,7 +51,7 @@
51
51
  "name": "two-stroke",
52
52
  "packageManager": "yarn@4.3.0",
53
53
  "type": "module",
54
- "version": "1.0.32",
54
+ "version": "1.0.34",
55
55
  "devDependencies": {
56
56
  "@types/eslint": "^8.56.10",
57
57
  "@types/node": "^20.14.10",
package/src/index.ts CHANGED
@@ -147,17 +147,30 @@ export function twoStroke<T extends Env>(title: string, release: string) {
147
147
  });
148
148
  }
149
149
  }
150
- const headers = new Headers(response.headers ?? {});
151
- if (!headers.has("Content-Type"))
152
- headers.set("Content-Type", "application/json");
153
- if (!headers.has("Access-Control-Allow-Origin"))
154
- headers.set("Access-Control-Allow-Origin", "*");
150
+ const responseWithHeaders: Omit<typeof response, "headers"> & {
151
+ headers: Headers;
152
+ } = {
153
+ ...response,
154
+ headers: new Headers(response.headers ?? {}),
155
+ };
156
+ if (!responseWithHeaders.headers.has("Content-Type"))
157
+ responseWithHeaders.headers.set(
158
+ "Content-Type",
159
+ "application/json",
160
+ );
161
+ if (!responseWithHeaders.headers.has("Access-Control-Allow-Origin"))
162
+ responseWithHeaders.headers.set(
163
+ "Access-Control-Allow-Origin",
164
+ "*",
165
+ );
166
+
155
167
  return new Response(
156
168
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
157
- headers.get("Content-Type") === "application/json"
169
+ responseWithHeaders.headers.get("Content-Type") ===
170
+ "application/json"
158
171
  ? JSON.stringify(response.body)
159
172
  : response.body,
160
- response,
173
+ responseWithHeaders,
161
174
  );
162
175
  }
163
176
  }