@moostjs/event-http 0.2.1 → 0.2.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/dist/index.cjs +4 -4
- package/dist/index.mjs +5 -5
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -233,7 +233,7 @@ function useBody() {
|
|
|
233
233
|
return JSON.parse(v);
|
|
234
234
|
}
|
|
235
235
|
catch (e) {
|
|
236
|
-
throw new eventHttp.
|
|
236
|
+
throw new eventHttp.HttpError(400, e.message);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
function textParser(v) {
|
|
@@ -242,7 +242,7 @@ function useBody() {
|
|
|
242
242
|
function formDataParser(v) {
|
|
243
243
|
const boundary = '--' + (/boundary=([^;]+)(?:;|$)/.exec(contentType || '') || [, ''])[1];
|
|
244
244
|
if (!boundary)
|
|
245
|
-
throw new eventHttp.
|
|
245
|
+
throw new eventHttp.HttpError(eventHttp.EHttpStatusCode.BadRequest, 'form-data boundary not recognized');
|
|
246
246
|
const parts = v.trim().split(boundary);
|
|
247
247
|
const result = {};
|
|
248
248
|
let key = '';
|
|
@@ -273,13 +273,13 @@ function useBody() {
|
|
|
273
273
|
if (line.toLowerCase().startsWith('content-disposition: form-data;')) {
|
|
274
274
|
key = (/name=([^;]+)/.exec(line) || [])[1];
|
|
275
275
|
if (!key)
|
|
276
|
-
throw new eventHttp.
|
|
276
|
+
throw new eventHttp.HttpError(eventHttp.EHttpStatusCode.BadRequest, 'Could not read multipart name: ' + line);
|
|
277
277
|
continue;
|
|
278
278
|
}
|
|
279
279
|
if (line.toLowerCase().startsWith('content-type:')) {
|
|
280
280
|
partContentType = (/content-type:\s?([^;]+)/i.exec(line) || [])[1];
|
|
281
281
|
if (!partContentType)
|
|
282
|
-
throw new eventHttp.
|
|
282
|
+
throw new eventHttp.HttpError(eventHttp.EHttpStatusCode.BadRequest, 'Could not read content-type: ' + line);
|
|
283
283
|
continue;
|
|
284
284
|
}
|
|
285
285
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WooksHttp, createHttpApp, useHttpContext, useRequest, useHeaders,
|
|
1
|
+
import { WooksHttp, createHttpApp, useHttpContext, useRequest, useHeaders, HttpError, EHttpStatusCode, WooksURLSearchParams, useStatus, useSetHeader, useSetCookie, useAuthorization, useCookies, useSearchParams, useResponse } from '@wooksjs/event-http';
|
|
2
2
|
import { getMoostMate, Resolve } from 'moost';
|
|
3
3
|
|
|
4
4
|
/******************************************************************************
|
|
@@ -231,7 +231,7 @@ function useBody() {
|
|
|
231
231
|
return JSON.parse(v);
|
|
232
232
|
}
|
|
233
233
|
catch (e) {
|
|
234
|
-
throw new
|
|
234
|
+
throw new HttpError(400, e.message);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
function textParser(v) {
|
|
@@ -240,7 +240,7 @@ function useBody() {
|
|
|
240
240
|
function formDataParser(v) {
|
|
241
241
|
const boundary = '--' + (/boundary=([^;]+)(?:;|$)/.exec(contentType || '') || [, ''])[1];
|
|
242
242
|
if (!boundary)
|
|
243
|
-
throw new
|
|
243
|
+
throw new HttpError(EHttpStatusCode.BadRequest, 'form-data boundary not recognized');
|
|
244
244
|
const parts = v.trim().split(boundary);
|
|
245
245
|
const result = {};
|
|
246
246
|
let key = '';
|
|
@@ -271,13 +271,13 @@ function useBody() {
|
|
|
271
271
|
if (line.toLowerCase().startsWith('content-disposition: form-data;')) {
|
|
272
272
|
key = (/name=([^;]+)/.exec(line) || [])[1];
|
|
273
273
|
if (!key)
|
|
274
|
-
throw new
|
|
274
|
+
throw new HttpError(EHttpStatusCode.BadRequest, 'Could not read multipart name: ' + line);
|
|
275
275
|
continue;
|
|
276
276
|
}
|
|
277
277
|
if (line.toLowerCase().startsWith('content-type:')) {
|
|
278
278
|
partContentType = (/content-type:\s?([^;]+)/i.exec(line) || [])[1];
|
|
279
279
|
if (!partContentType)
|
|
280
|
-
throw new
|
|
280
|
+
throw new HttpError(EHttpStatusCode.BadRequest, 'Could not read content-type: ' + line);
|
|
281
281
|
continue;
|
|
282
282
|
}
|
|
283
283
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-http",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "@moostjs/event-http",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-http#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.
|
|
32
|
-
"wooks": "^0.2.
|
|
31
|
+
"moost": "0.2.3",
|
|
32
|
+
"wooks": "^0.2.5"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@wooksjs/event-http": "^0.2.
|
|
35
|
+
"@wooksjs/event-http": "^0.2.5"
|
|
36
36
|
}
|
|
37
37
|
}
|