import * as typeIs from 'type-is' ; import { pipe } from 'fp-ts/lib/function' ; import { Observable } from 'rxjs' ; import { map , toArray } from 'rxjs/operators' ; import { HttpRequest } from '@marblejs/http' ; import { getContentTypeUnsafe } from '@marblejs/http/dist/+internal/contentType.util' ; import { fromReadableStream } from '@marblejs/core/dist/+internal/observable' ; export const matchType = ( type ) => ( req ) : boolean => ! ! typeIs . is ( getContentTypeUnsafe ( req . headers ) , type ) ; export const isMultipart = ( req ) : boolean => getContentTypeUnsafe ( req . headers ) . includes ( 'multipart/' ) ; export const hasBody = ( req ) : boolean => req . body !== undefined && req . body !== null ; export const getBody = ( req ) : Observable < Buffer > => pipe ( fromReadableStream ( req ) , toArray ( ) , map ( chunks => Buffer . concat ( chunks ) ) ) ;