@byu-oit-sdk/middleware-stack
TypeScript icon, indicating that this package has built-in type declarations

0.6.3 • Public • Published

@byu-oit-sdk/middleware-stack

For a deep-dive on the middleware stack, please read the Introducing Middleware Stack in Modular AWS SDK for JavaScript .

For an example of how to create middleware, please see the Token Middleware or Retry Middleware

Usage

The middleware stack consists of three parts: initialization, transformation, and finalization. It uses a standard stack architecture, meaning that it goes from initialization -> transformation -> finalization -> terminator -> finalization -> transformation -> initialization. The request moves through the stages in order until it reaches the "terminator" and the command is executed, at which point a response is sent back down the stack to be changed to what the sender is expecting to receive.

Initializtion

This stage of the middleware stack initializes an API call. Typically this step adds default input values to a command. The HTTP request has not been constructed by this point. When the response is passed through, it is finalized to ensure it is readable to the program that sent the request.

Transformation

This stage deals with the serialization of the request when moving up the stack, and deserialization when moving down the stack. "Transformation" simply refers to changing the request and response to be in the correct format. In this stage an HTTP request is constructed for the API call. Tasks include input validation and building the HTTP request from user input. When the response object returns through this middleware, it is converted from an HTTP response into a structured object that matches the expectations of the client.

Finalization

This stage alters the now-serialized request to ensure it matches the recipient's expectations. Examples of typical finalization tasks include adding an authorization header and performing retries.

Readme

Keywords

none

Package Sidebar

Install

npm i @byu-oit-sdk/middleware-stack

Weekly Downloads

261

Version

0.6.3

License

Apache-2.0

Unpacked Size

90.7 kB

Total Files

25

Last publish

Collaborators

  • byu-oit-bot
  • stuft2