Stacked is a stand-alone, lightweight, and zero-dependency utility for bundling multiple middleware functions into a single, cohesive stack. Inspired by `connect`'s middleware infrastructure, it provides a `use` and `mount` API for composing HTTP middleware. As of its last published version, 1.1.1, the package has not seen updates since April 2017, indicating it is no longer actively maintained. Its key differentiator lies in its minimalist design, offering core middleware stacking functionality without the overhead or additional features found in more comprehensive frameworks. It is suitable for projects requiring a simple, independent middleware composition tool, particularly in environments compatible with its older CommonJS module format.
npm install stackedVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `stacked`, register multiple global middleware functions using `.use()`, and mount a specific middleware to a path using `.mount()`. It sets up a basic HTTP server to showcase how `stacked` handles incoming requests through the defined middleware chain, including path-specific logic.
Consider migrating to actively maintained middleware frameworks like Express.js or Koa.js, or re-implementing the middleware stacking logic using native Node.js HTTP modules for better long-term support and security.
In an ESM project, if `stacked` is indispensable, use `const stacked = await import('stacked');` for asynchronous loading, or ensure your build system properly transpiles CommonJS modules. For new projects, prefer ESM-compatible middleware solutions.Always use `req.originalUrl` when the full request path is needed within mounted middleware. Be mindful that `req.url` inside a mounted middleware will be the path *relative* to the mount point, not the full path.
Ensure `const stacked = require('stacked');` is used in CommonJS environments. In ESM, if you must use it, `const { default: stacked } = await import('stacked');` might work, but it's not guaranteed without specific configuration.If your project is CommonJS, stick to `const stacked = require('stacked');`. If your project is ESM, either configure Node.js and TypeScript to correctly handle CommonJS interop, or use dynamic import `const { default: stacked } = await import('stacked');`.No dependency data recorded yet.