# @byu-oit-sdk/middleware-stack

> A middleware stack implementation that resolves to one method to pass input/output down and up the stack

Latest version **0.9.0** (published 2026-04-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @byu-oit-sdk/middleware-stack
pnpm add @byu-oit-sdk/middleware-stack
yarn add @byu-oit-sdk/middleware-stack
bun add @byu-oit-sdk/middleware-stack
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2026-04-29 |
| First published | 2022-11-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 2 |
| Unpacked size | 87.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Spencer Tuft |
| Maintainers | stuft2, byu-oit-bot |

## Links

- npm: https://www.npmjs.com/package/@byu-oit-sdk/middleware-stack
- Repository: https://github.com/byu-oit-sdk/javascript
- Homepage: https://github.com/byu-oit-sdk/javascript#readme
- Issues: https://github.com/byu-oit-sdk/javascript/issues
- npm.io page: https://npm.io/package/@byu-oit-sdk/middleware-stack

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.5.0
- [lodash.remove](https://npm.io/package/lodash.remove.md) ^4.7.0

## Recent versions

- 0.9.0 (latest) — 2026-04-29
- 0.8.0 — 2026-04-06
- 0.7.0 — 2025-07-22
- 0.6.3 — 2024-07-27
- 0.6.2 — 2024-07-27
- 0.6.1 — 2024-02-27
- 0.6.1-beta.1 — 2024-02-27
- 0.6.1-beta.0 — 2024-02-01
- 0.6.0 — 2023-09-21
- 0.6.0-beta.1 — 2023-08-23
- 0.6.0-beta.0 — 2023-08-23
- 0.5.2-beta.0 — 2023-08-21
- 0.5.1 — 2023-07-07
- 0.5.0 — 2023-06-28
- 0.4.0 — 2023-06-22
- … 10 more at https://npm.io/package/@byu-oit-sdk/middleware-stack/versions

## README

# @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](https://aws.amazon.com/blogs/developer/middleware-stack-modular-aws-sdk-js/)
.

For an example of how to create middleware, please see the [Token Middleware](https://byu-oit-sdk.github.io/javascript/modules/Middleware_Token.html) or [Retry Middleware](https://byu-oit-sdk.github.io/javascript/modules/Middleware_Retry.html)

## 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.

---
_Source: https://npm.io/package/@byu-oit-sdk/middleware-stack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
