finds.dev← search

// the find

luin/express-promise

★ 316 · JavaScript · MIT · updated Nov 2015

❤️ Middleware for easy rendering of async Query results.

A 2013-era Express middleware that lets you pass promise-returning functions directly to res.json/res.send/res.render, and it resolves them before sending. Solves a real problem that existed before async/await: deeply nested promise chains in route handlers. The target audience no longer exists.

- The core idea is clean — intercepting the response methods and recursively resolving promises in the payload is a neat monkey-patch that required no changes to route handler signatures

- The skipTraverse option shows some awareness of real-world ORM objects where calling toJSON strips methods you might need in templates

- Good test coverage across the main methods (send, json, render) and edge cases like recursive objects

- Dead since 2015 — async/await landed in Node 7.6 (2017) and made this entire pattern obsolete; any new project reaching for this has taken a wrong turn

- Recursive object traversal to find promises is fragile and slow — it will walk your entire response payload looking for thenables, with no depth limit visible in the code

- The implicit 'pass a promise and it resolves' contract is invisible to anyone reading route code; a new developer sees res.json({ user: User.find() }) and has no idea why it works until they find the middleware

- No error handling path shown in the README — if one of three nested promises rejects, it's unclear whether you get a 500, a silent hang, or a partial response

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →