@bool-ts/core 1.4.1 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bool-ts/core",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -141,32 +141,53 @@ export const BoolFactory = (target: new (...args: any[]) => unknown, options: TB
141
141
  try {
142
142
  const reqHeaders = request.headers;
143
143
  const origin = reqHeaders.get("origin");
144
+ const resHeaders = new Headers({
145
+ "Access-Control-Allow-Origin": origin || "*",
146
+ "Access-Control-Allow-Headers": "*",
147
+ "Access-Control-Allow-Credentials": "true",
148
+ "Access-Control-Allow-Methods": allowMethods.join(", "),
149
+ "Content-Type": "application/json"
150
+ });
144
151
 
145
152
  if (!allowOrigins.includes("*")) {
146
153
  if (!origin) {
147
- throw new HttpClientError({
148
- httpCode: 403,
149
- message: "Origin not found.",
150
- data: {
151
- origin: {
152
- code: "origin:invalid:0x00001",
153
- message: "Origin not found."
154
+ return new Response(
155
+ JSON.stringify({
156
+ httpCode: 403,
157
+ message: "Origin not found.",
158
+ data: {
159
+ origin: {
160
+ code: "origin:invalid:0x00001",
161
+ message: "Origin not found."
162
+ }
154
163
  }
164
+ }),
165
+ {
166
+ status: 403,
167
+ statusText: "Origin not found.",
168
+ headers: resHeaders
155
169
  }
156
- });
170
+ );
157
171
  }
158
172
 
159
173
  if (!allowOrigins.includes(origin)) {
160
- throw new HttpClientError({
161
- httpCode: 403,
162
- message: "Invalid origin.",
163
- data: {
164
- origin: {
165
- code: "origin:invalid:0x00002",
166
- message: "Invalid origin."
174
+ return new Response(
175
+ JSON.stringify({
176
+ httpCode: 403,
177
+ message: "Origin not found.",
178
+ data: {
179
+ origin: {
180
+ code: "origin:invalid:0x00002",
181
+ message: "Invalid origin."
182
+ }
167
183
  }
184
+ }),
185
+ {
186
+ status: 403,
187
+ statusText: "Invalid origin.",
188
+ headers: resHeaders
168
189
  }
169
- });
190
+ );
170
191
  }
171
192
  }
172
193
 
@@ -274,14 +295,6 @@ export const BoolFactory = (target: new (...args: any[]) => unknown, options: TB
274
295
  responseBody = responseData;
275
296
  }
276
297
 
277
- const resHeaders = new Headers({
278
- "Access-Control-Allow-Origin": origin || "*",
279
- "Access-Control-Allow-Headers": "*",
280
- "Access-Control-Allow-Credentials": "true",
281
- "Access-Control-Allow-Methods": allowMethods.join(", "),
282
- "Content-Type": "application/json"
283
- });
284
-
285
298
  const response = new Response(
286
299
  JSON.stringify({
287
300
  httpCode: 200,