app-builder is a JavaScript library for creating robust and composable asynchronous middleware pipelines, following the 'onion' model commonly seen in frameworks like Koa. It leverages Promises to enable clear and sequential execution of middleware functions, each capable of performing operations before and after subsequent middleware in the stack. The current stable version is 7.0.4. While a specific release cadence isn't explicitly stated, the active GitHub repository suggests ongoing maintenance. Its key differentiator lies in its simplicity and functional approach to middleware composition, providing a lightweight alternative to larger frameworks for building request-response flows or general data processing pipelines. It ships with TypeScript types, ensuring a better developer experience in TypeScript projects.
npm install app-builderVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to compose asynchronous middleware functions into a pipeline, including logging, core logic, and robust error handling, showcasing both successful and failing scenarios.
Always ensure `await next()` is used when calling the next middleware in an `async` function if you expect control to return to the current middleware after the inner stack has completed.
Implement an error-handling middleware that wraps `await next()` in a `try/catch` block, or ensure individual middleware functions handle their own potential errors.
Establish clear conventions for context properties and their expected types/values at each stage of the pipeline. Consider using immutable data patterns or a more structured context object where applicable.
Wrap `await next()` calls in a `try/catch` block within your middleware, or ensure an error-handling middleware is correctly positioned at the beginning of your pipeline to catch errors from subsequent middleware.
Ensure all functions passed to `compose` adhere to the `async (ctx, next)` signature, even if `next` is not used. Verify the order of arguments.
Always use `await next()` in `async` middleware functions to ensure the 'onion' model's control flow is maintained and execution returns to the current middleware after the inner stack is complete.
No dependency data recorded yet.