RawRequest
@h4ad/serverless-adapter > RawRequest
(class) RawRequest
The class that expose some methods to be used to get raw request from Express HTTP Request
Signature:
export declare abstract class RawRequest<TApp>
(method) getRequestFromExpressRequest
Not sure why they think using Express instance with prebuilt middlewares was a good idea, but Firebase/GCP decides to use Express
and body-parser
by default, so you don't get a raw request, instead, you get a modified version by Express and also with the body parsed by body-parser
. If you use NestJS or Express it's awesome, but for the rest of the frameworks it's terrible! That's why I have this method, just to try and create a raw request to be used and passed to the frameworks so they can handle the request as if they received the request from the native http module.
Signature:
protected getRequestFromExpressRequest(request: IncomingMessage): ServerlessRequest;
Parameters
Parameter | Type | Description |
---|---|---|
request | IncomingMessage | The Express request |
Returns:
(method) onRequestCallback
The callback to when receive some request from external source
Signature:
protected onRequestCallback(app: TApp, framework: FrameworkContract<TApp>): (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
app | TApp | The instance of the app |
framework | FrameworkContract <TApp> | The framework for the app |
Returns:
(req: IncomingMessage, res: ServerResponse) => void | Promise<void>