import { Request } from 'express'; import Server from '../Server.js'; /** * Represents the response object returned by a generic event handler. * @typedef {Object} GenericHandlerEventResponse * @property {Error | string} [err] - An optional error object or error message. * @property {*} [data] - An optional data object. */ export type GenericHandlerEventResponse = { err?: Error | string; data?: any; }; /** * Represents a generic handler event for serverless functions. */ export default class GenericHandlerEvent { /** * Represents an HTTP request. * @property {Request} request - The HTTP request object. */ request: Request; /** * The handler function for serverless events in a server. * @param {Server['handleServerlessEvent']} serverlessHandler - The function that handles serverless events. * @returns None */ serverlessHandler: Server['handleServerlessEvent']; /** * Constructs a new instance of the class. * @param {Request} request - The request object. * @param {Server['handleServerlessEvent']} serverlessHandler - The serverless handler function. * @returns None */ constructor(request: Request, serverlessHandler: Server['handleServerlessEvent']); /** * Invokes the handler function asynchronously and returns a promise that resolves to a GenericHandlerEventResponse. * @returns {Promise} A promise that resolves to a GenericHandlerEventResponse. */ invoke(): Promise; /** * Builds and returns an APIGatewayProxyEvent object based on the current request. * @returns {APIGatewayProxyEvent} - The constructed APIGatewayProxyEvent object. */ private buildEvent; /** * Builds and returns a context object for an AWS Lambda function. * @param {APIGatewayProxyEvent} event - The event object passed to the Lambda function. * @param {(err?: Error | string, data?: any) => void} callback - The callback function to be called when the Lambda function completes. * @returns {Context} - The context object for the Lambda function. */ private buildContext; }