UNPKG

@h4ad/serverless-adapter

Version:

Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure, Digital Ocean and many other clouds.

33 lines (30 loc) 1.55 kB
import { IncomingMessage, ServerResponse } from 'http'; import { S as ServerlessRequest } from './request-DsBcr1WD.cjs'; import { F as FrameworkContract } from './framework.contract-td-lRvq6.cjs'; /** * The class that expose some methods to be used to get raw request from Express HTTP Request * * @breadcrumb Handlers / Base / RawRequest * @public */ declare abstract class RawRequest<TApp> { /** * The callback to when receive some request from external source * * @param app - The instance of the app * @param framework - The framework for the app */ protected onRequestCallback(app: TApp, framework: FrameworkContract<TApp>): (req: IncomingMessage, res: ServerResponse) => void | Promise<void>; /** * 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. * * @param request - The Express request */ protected getRequestFromExpressRequest(request: IncomingMessage): ServerlessRequest; } export { RawRequest as R };