Code Monkey home page Code Monkey logo

Comments (5)

jonathanong avatar jonathanong commented on March 29, 2024

since we're doing this.request and this.response, would be nice if the signature was:

app.use(function* (req, res) {
  assert(this.request === req);
  assert(this.response === res);
})

because doing this.request and this.response or var req = this.request would be pretty annoying. of course this shouldn't be necessary since a lot of properties are delegated to this, but i don't see the harm of passing these as arguments. it would also make it more similar to express, especially if you decided to make express 4.0 an opinionated version of koa.

from koa.

jonathanong avatar jonathanong commented on March 29, 2024

possible implementation: koajs/compose#1

variable arity would be pretty simple to do if we compose this way.

from koa.

tj avatar tj commented on March 29, 2024

the one thing I like about not using arguments at all is that it frees up args for stuff like koa-route parameters. which could still use this.request but then it kind of diverges more from other koa related code, but definitely worth a consideration it does look better than if (this.response.header[blahblah]). The other reason I like it being on this is that it's reasonably obvious that those are not node's request/response objects since it doesn't match express

hopefully we don't even use those very much in every-day koa code, it just gets awkward with a few of those properties we had. On the other hand I'm totally cool with just doing this.params again in koa-route, not a huge deal

from koa.

jonathanong avatar jonathanong commented on March 29, 2024

hmmm i'm actually liking doing this.request and this.response and it's probably better for users not to worry about arity (as you know, i hate when people check a function's arity. :P). should we close this?

from koa.

tj avatar tj commented on March 29, 2024

yeah might as well close for now I don't have super strong opinions on it, keeps the signature nice and clean :D

from koa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.