Skip to main content

BaseBodyParserFramework

@h4ad/serverless-adapter > BaseBodyParserFramework

(class) BaseBodyParserFramework

The base class used by other body-parser functions to parse a specific content-type

Signature:

export declare class BaseBodyParserFramework<TApp> implements FrameworkContract<TApp> 

Implements: FrameworkContract <TApp>

(constructor)

Default Constructor

Signature:

protected constructor(framework: FrameworkContract<TApp>, middleware: NextHandleFunction, options?: BodyParserOptions | undefined);

Parameters

ParameterTypeDescription
frameworkFrameworkContract <TApp>
middlewareNextHandleFunction
optionsBodyParserOptions | undefined(Optional)

(method) defaultHandleOnError

The default function to handle errors

Signature:

protected defaultHandleOnError(_request: IncomingMessage, response: ServerResponse, error: HttpError<any>): void;

Parameters

ParameterTypeDescription
_requestIncomingMessageThe referecene for request
responseServerResponseThe reference for response
errorHttpError<any>The error throwed by body-parser

Returns:

void

(property) errorHandler

The selected error handler

Signature:

protected readonly errorHandler: NonNullable<BodyParserOptions['customErrorHandler']>;

(property) framework

Signature:

protected readonly framework: FrameworkContract<TApp>;

(property) middleware

Signature:

protected readonly middleware: NextHandleFunction;

(method) onBodyParserFinished

Handle next execution called by the cors package

Signature:

protected onBodyParserFinished(app: TApp, request: IncomingMessage, response: ServerResponse): () => void;

Parameters

ParameterTypeDescription
appTApp
requestIncomingMessage
responseServerResponse

Returns:

() => void

(property) options

Signature:

protected readonly options?: BodyParserOptions | undefined;

(method) sendRequest

Signature:

sendRequest(app: TApp, request: IncomingMessage, response: ServerResponse): void;

Parameters

ParameterTypeDescription
appTApp
requestIncomingMessage
responseServerResponse

Returns:

void