Search⌘ K
AI Features

Request Processor and Concrete Adapters

Explore how to build a request processor using ports and adapters within AWS Lambda applications. Learn to isolate business logic for unit testing, implement concrete AWS S3 signer adapters, and manage deployment packaging by excluding test resources. This lesson guides you to design robust, testable serverless functions by separating core workflows from infrastructure dependencies.

For the ShowFormFunction handler, the core business logic is to validate that a requested upload has an extension and that the extension belongs to a list of approved file types. For valid extensions, the function needs to create a unique upload file name based on the request ID and the extension, and produce a signed upload policy and a signed download policy. This business core will have three ports (shown in the figure provided below):

  1. The first port should provide the request ID and the extension, starting the process, and format the resulting signatures accordingly.
  2. The second port should sign upload policies based on a key.
  3. The third port should sign download policies based on a key.

The core business logic should not care about AWS interfaces, but instead describe the workflow using concepts important for a specific use case, such as signing uploads and downloads. You can create a new file called request-processor.js in the user-form ...