koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.07k stars 3.22k forks source link

docs: Fix definition of middleware in guide.md #1810

Closed dsommerich closed 3 months ago

dsommerich commented 4 months ago

This PR is to fix the definition of what a middleware is in guide.md. The old definition says that middleware are "simple functions which return a MiddlewareFunction", however every other peice of documentation I could find refers to the MiddlewareFunction itself as the middleware (not the function that returns the MiddlewareFunction).

If the old definition is intentional and correct, I'm happy to close this PR, but it really seems like it's not correct. E.g. the very next sentence says "When the middleware is run, it must manually invoke next()", however if a middleware is the function that returns the MiddlewareFunction then it wouldn't be able to invoke next() since next is passed to the MiddlewareFunction not the function that returns the MiddlewareFunction.

Sorry if this is pedantic, we just had a bit of a back-and-forth on this in a PR and I decided to actually be productive and fix it instead of just complaining to coworkers 😅.

Checklist