node-async-router
node-async-router copied to clipboard
Replacing express.Router()?
Are these two lines equivalent?
var router = require('express').Router()
var router = require('node-async-router')()
If that's correct, its still very simple to replace the built in router (see also https://expressjs.com/en/guide/routing.html#express-router ), but it might also be useful to mention this in the readme.
If I understand correctly, you're asking if there's any reason to use the Router exported by this module, as opposed to the one exported by Express? If so, then the answer is yes. This module works by patching pillarjs/router (which was originally extracted from Express, but removes the Express dependency).
Without applying these patches, async route handlers that resolve to a rejected Promise won't be handled correctly.
Sorry, that's not what I meant. "equivalent" was not a good choice.
Since your example is for the standalone router package, but I'm using the built-in Router from Express, I was looking for a confirmation that the two are compatible.
pillarjs/router itself doesn't claim any explicit compatibility with Express - I guess the term "middleware" implies it?
Ahh, I'm not sure I'm 100% comfortable in asserting complete compatibility. I'm not specifically aware of any differences, and when we migrated a pretty large codebase over to this module, there weren't any issues.
Hopefully @dougwilson wouldn't object to weighing in on this, as he's still active in both repos? TL;DR: is pillarjs/router still API-compatible enough with express.Router to advertise as a drop-in replacement, or are their known incompatibilities at this point?