Closed jsmadja closed 8 years ago
Take a look at #92 - you can disable the body parser by providing the relevant option. I didn't try it with PUT but it should work the same way
As you can see, I'm using the parameter parseBody: false. I tried with true value, but my problem is I don't know why my body is not auto-unmarshalled (string to object) anymore since my migration from Seneca 2.1.
@jsmadja The current behaviour with parseBody:true
should work for you, if not, it is a bug. #92 added the ability to turn it off, not remove it.
What output are you getting with parseBody defaulted to true? We may need to make parseBody:true more robust. The old implementation used Express' body parser to auto marshal. This became a problem when we went to implement things like hapi.
The new body parser is pretty lightweight and more to enable basic fallback. We can certainly enhance the new parser but I would be against adding back in BodyParser as it is something that is best configured external to seneca-web.
As for why the change generally. Seneca web became super hard to maintain and was becoming stagnant. Features took far too long to add and load order was unreliable. Overall the minor configuration shortcuts were not worth it in the end.
Apologies, I didn't read your issue as close as I should have. After looking a little closer I think I see the problem: the option needs to be passed like the following -- wrapped in an options
key -- see readme:
.use(SenecaWeb, {
routes: Routes,
context: express,
adapter: require('seneca-web-adapter-express'),
options: {parseBody: false}
})
The behavior you are seeing (stringified response) is the way the built-in body parser works currently. With both built-in parser and body-parser you'll see requests going off into the ether.
It works. I made a pull request with more documentation.
Hi,
I've got a problem. I was using Seneca 2.1 (before seneca-web became an external dependency with Seneca 3.x).
I'm trying to migrate my code and I have a problem with PUT request. They were in timeout. I've found the problem and it "works" when I remove
express.use(BodyParser.urlencoded({extended: true})) .use(BodyParser.json({limit: '50mb'}));
What I don't understand is : why I can't have a body auto-parsed like I had in Seneca 2.1
Without the BodyParser, I can see a msg.args.body as a string and not as an object.
Here the minimal code to reproduce my problem. Or you can git clone my repo : https://github.com/jsmadja/seneca-web-put
index.js
routes.js
plugin.js