two-stroke 1.0.33 → 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 +19 -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.33",
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,18 +147,30 @@ export function twoStroke<T extends Env>(title: string, release: string) {
147
147
  });
148
148
  }
149
149
  }
150
- response.headers = new Headers(response.headers ?? {});
151
- if (!response.headers.has("Content-Type"))
152
- response.headers.set("Content-Type", "application/json");
153
- if (!response.headers.has("Access-Control-Allow-Origin"))
154
- response.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
+ );
155
166
 
156
167
  return new Response(
157
168
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
158
- response.headers.get("Content-Type") === "application/json"
169
+ responseWithHeaders.headers.get("Content-Type") ===
170
+ "application/json"
159
171
  ? JSON.stringify(response.body)
160
172
  : response.body,
161
- response,
173
+ responseWithHeaders,
162
174
  );
163
175
  }
164
176
  }