dartist / express

A thin express-js inspired layer around Dart's primitive HttpServer APIs
Other
126 stars 11 forks source link

Create express body parser #21

Open SamVerschueren opened 10 years ago

SamVerschueren commented 10 years ago

Before ExpressJS 4.x, the bodyparser was part of the express library. But since 4.x they removed a lot of the built in functionality and created all seperate libraries (body-parser, csurf, session, ...). For now, it's only possible to retrieve simple body data submitted by a form. It would be a nice idea if we created a body-parser library that we can maintain seperately from the express library.

Later on we can even create extra libraries like csurf, session, ...

It's just an idea, what do you guys think?

mythz commented 10 years ago

A separate library at an early stage just adds friction and versioning issues. IMO better to keep things simple and have a more complete functioning core, then later extract out if need be, i.e. when there's interest in re-use of the body parsers outside of express. Until then just adds more burden on the user.

SamVerschueren commented 10 years ago

Yes your probably right. Would it be better to built it in in the core or create seperate classes? Something like this

var app = new Express();
app.use(new JSONBodyParser());
app.post('/api/user/create', (ctx) {
   var body = ctx.body;
});

Or you would rather see it like

var app = new Express();
app.post('/api/user/create', (ctx) {
   var body = ctx.body;
});
mythz commented 10 years ago

IMO core stuff like JSON should be baked in the box so users need not worry about it.

It would be nice to modularize it so JSON support can be encapsulated in a class and autoregistered by default, but then provide users an opportunity to remove the modules/features they don't want. I've enabled something like this in ServiceStack Plugins which enables the most popular plugins by default into a modifyable collection, which can later be introspected, added to and removed.

SamVerschueren commented 10 years ago

@mythz Would be nice to have something like that. Will look into if when I resolved the other issue. Didn't find the time yet

thosakwe commented 7 years ago

Super old issue, but if you're still looking for something like this, I built it over a year ago: https://github.com/thosakwe/body_parser

It's used in the Angel framework, which is a good alternative to this library, seeing as it hasn't been updated in years. https://github.com/angel-dart/angel/wiki