Skip to content

express.bodyParser({intended for formidable}) not assigning listeners #565

Closed
rayie opened this Issue May 11, 2012 · 2 comments

2 participants

@rayie
rayie commented May 11, 2012

minor feature request
if opts contain keys matching formidable event names such as "progress" and "fileBegin", they are not added as listeners but just plain key/val pairs on form

bodyParser.js (line 157)

157   Object.keys(options).forEach(function(key){
158     form[key] = options[key];
159   });

Not finding any other hook to the formidable.IncomingForm object, exposed by express, so no other oppotunity to add listeners to it when using app.use(express.bodyParser({...})

Maybe change to this:

157   Object.keys(options).forEach(function(key){
158     if (typeof options[key]=="function" )
159         form.on(key, options[key]);
160     else form[key] = options[key];
161   });

??

@tj
Sencha Labs member
tj commented May 15, 2012

this was why I broke bodyParser into multipart(), json() and urlencoded(), so that if you want to use formidable directly you can just omit multipart(). In the near future (or now if you only care about modern browsers) you dont need the server for progress updates anyway, but it would be cleaner to omit multipart() and use formidable directly if you're using events

@rayie
rayie commented May 15, 2012

Sounds good. I'll do that. Thanks.

@rayie rayie closed this May 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.