harbor run -t openthoughts/tasktrove-exp-rpt-stack-jest-large-stack-jest-0643harbor download openthoughts/tasktrove-exp-rpt-stack-jest-large-stack-jest-0643Task: Build a tiny, self-contained Express-like web framework in /app/
Goal Implement a minimal web framework that matches the behavior exercised by the provided Jest/Mocha tests. The framework should export a function express() that returns an app object which is also a callable HTTP handler. The app must support mounting middleware (including sub-apps), dynamic routing, path stripping, and a few convenience utilities used in the tests.
What to implement
module.exports = function express() { ... } // returns an app
The app object must be a function: app(req, res, next) { app.handle(req, res, next); }
The app must expose a lightweight event system:
The app must have a stack of layers: app.stack (initially []) where each layer represents a mounted middleware or route.
app.use(mw) and app.use(path, mw, ...) must support:
When mounting any middleware, also emit 'mount' on the mounted object (even if mounted with a path)
Path matching rules (see below for details)
Each layer has:
Path matching behavior:
When a path matches, before invoking the layer:
The app must implement a dispatch mechanism to process requests:
Convenience route registration
404 fallback
Acceptance criteria