fix(middleware-body): skip `multipart/*` content-type handling in default parser
MODIFY
packages/middleware-body/src/body.middleware.ts
packages/middleware-body/src/body.middleware.ts
import { HttpError, HttpStatus, HttpMiddlewareEffect } from '@marblejs/core';
import { of, throwError, iif } from 'rxjs';
-import { catchError, map, switchMap, tap, mapTo } from 'rxjs/operators';
+import { catchError, map, switchMap, tap, mapTo, mergeMap } from 'rxjs/operators';
import { defaultParser } from './parsers';
import { RequestBodyParser } from './body.model';
-import { matchType, getBody, hasBody } from './body.util';
+import { matchType, getBody, hasBody, isMultipart } from './body.util';
const PARSEABLE_METHODS = ['POST', 'PUT', 'PATCH'];
@@ -21,8 +21,10 @@ export const bodyParser$ = ({
() =>
PARSEABLE_METHODS.includes(req.method)
&& !hasBody(req)
+ && !isMultipart(req)
&& matchType(type)(req),
- getBody(req).pipe(
+ of(req).pipe(
+ mergeMap(getBody),
map(parser(req)),
tap(body => req.body = body),
mapTo(req),

MODIFY
packages/middleware-body/src/body.util.ts
packages/middleware-body/src/body.util.ts
@@ -6,6 +6,9 @@ import { map, toArray } from 'rxjs/operators';
export const matchType = (type: string[]) => (req: HttpRequest) =>
!!typeIs.is(getContentType(req.headers), type);
+export const isMultipart = (req: HttpRequest): boolean =>
+ getContentType(req.headers).includes('multipart/')
+
export const hasBody = (req: HttpRequest): boolean =>
req.body !== undefined && req.body !== null;

fix(middleware-body): skip `multipart/*` content-type handling in default parser