expressjs / express

Fast, unopinionated, minimalist web framework for node.
https://expressjs.com
MIT License
65.81k stars 16.46k forks source link

Express should make POST data available by default #1148

Closed davedx closed 12 years ago

davedx commented 12 years ago

Currently, you have to explicitly tell express to use the connect middleware before you can access POST data.

I believe that in the spirit of convention over configuration, this should be enabled by default. Express isn't a microframework (it has templating, routing and other stuff), so I think support for basic things like this should be out of the box.

I'm happy to have a go at forking this if it would be accepted :)

Thoughts?

buschtoens commented 12 years ago

Express is a "Fast, unopinionated, minimalist web framework for node". I don't see a problem in adding one line of code to your app: app.use(express.bodyParser()); It's easier to opt-in then to opt-out.

Express isn't a microframework (it has templating, routing and other stuff), so I think support for basic things like this should be out of the box.

This argument is invalid. :P How do you enable these features? You app.use(express.feature()); them. So why not do it with the bodyParser too? Besides that, even the simplest feature ever, static file serving, is enabled via app.use(express.static(__dirname + '/public'));.

I think the way Express handles it by now is optimal.

davedx commented 12 years ago

Why would anyone want to opt-out out of being able to process HTTP POST? Can you give a single use case?

I agree my argument wasn't very well put :P But my point stands that even a minimalist web framework should be able to grok the 2nd most used HTTP verb without "middleware". Oh well, it's an opinion, fair enough if people don't agree. :)

buschtoens commented 12 years ago

Imagine you have an app which is supposed to only do some static file serving and parsing templates with data of a database. Some kind of public statistics viewer. I know that apps like this are very raw, but they do exist and people don't need POST and friends there.

Actually I share your opinion. POST is some very basic stuff and I need it almost every second request, but we should care about the folks who don't need that stuff, since we promise to be a minimalistic (atomistic) web framewrok.