Skip to content

EventV1Processor

reference
1 min readUpdated

Kind: Class

Source: src/adapter/aws-lambda/handler.ts

Part of: Adapter

EventV1Processor adapts an AWS Lambda event in the V1 format into request data used by the handler layer. It reads the path, method, query string, cookies, and headers, then writes response cookies back to the Lambda result.

Extends: EventProcessor

Methods

MethodSignatureReturns
getPathgetPath(event: APIGatewayProxyEvent)string
getMethodgetMethod(event: APIGatewayProxyEvent)string
getQueryStringgetQueryString(event: APIGatewayProxyEvent)string
getCookiesgetCookies(_event: APIGatewayProxyEvent, _headers: Headers)void
getHeadersgetHeaders(event: APIGatewayProxyEvent)Headers
setCookiesToResultsetCookiesToResult(result: APIGatewayProxyResult, cookies: string[])void

Diagram

mermaid
graph LR
  Event[AWS Lambda V1 Event] --> Processor[EventV1Processor]
  Processor --> Path[getPath]
  Processor --> Method[getMethod]
  Processor --> Query[getQueryString]
  Processor --> Headers[getHeaders]
  Processor --> Cookies[getCookies]
  Processor --> Result[Lambda Result]
  Cookies --> SetCookies[setCookiesToResult]
  SetCookies --> Result

Usage

ts
import { EventV1Processor } from './adapter/aws-lambda/handler'

async function handleLambdaEvent(event: any, result: any) {
  const processor = new EventV1Processor(event, result)

  processor.getCookies()

  const request = new Request(
    `https://lambda.local${processor.getPath()}${processor.getQueryString()}`,
    {
      method: processor.getMethod(),
      headers: processor.getHeaders(),
    },
  )

  const response = await app.fetch(request)

  result.statusCode = response.status
  result.body = await response.text()

  processor.setCookiesToResult()

  return result
}

AI Coding Instructions

  • Keep event parsing inside EventV1Processor; downstream handlers should work with normalized request values.
  • Call getCookies() before request handling when cookie data must be available through request headers.
  • Call setCookiesToResult() after response processing so response cookies are written to the Lambda result.
  • Preserve the Headers return type from getHeaders() rather than converting headers into a plain object unless required by an integration.
  • Treat query strings and cookies as transport data; avoid rebuilding them in application handlers.

Was this page helpful?

Download as PDF
EventV1Processor — Hono (narrator proof)