-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hapi Plugin Decoration not present in Controller #99
Comments
I found the issue is related to the raw nodejs request being used: lib/hapi_middleware.js:28
|
I wish I'd found this issue before I spent 3 hours tracking down the issue and arriving at the same solution. :) |
@arosboro I've discovered it's much more complex than this simple fix.... For example the bodyParser (for parameters) expect the |
great, hopefully you can figure something out. I don't have many dependencies for other middleware, but I'm glad this is getting attention. |
@theganyo - is this something I should work on more? (I guess the question could be "am I using swagger-node-runner correctly"). The issue here is that the hapi_middleware replaces the 'internals' request object that hapi passes around. I'm guessing it does so in order that the bodyParser has access to teh input stream. The consequernce of this is that a controller can't use any other middleware that decorates the request object- effectively rendering this project useless for anything other than trivial apps. (We use Dogwater/Waterline ORM for example which expects you to have access to req.server and req.dogwater() etc). |
Hey Mark, |
Developing a fitting is probably the best way forward - but it'll take me some time. Until then, I'm afraid the swagger-hapi module is pretty much useful only for trivial tasks. I'll see if I can migrate the deltas into a fitting - at least that'll isolate them from the parameter parsing codebase. Do you know if there was any other reason (other than parameter parsing that is) why the raw request was selected by the hapi middleware? |
Yes, this issue is quite unfortunate. No, I don't know exactly why the raw request was necessary... but I think that the Hapi request had a naming collision with some method or property on the node request that caused it to have different semantics. Sorry, I don't have more specific information on that. |
Could we deep clone |
I'm attempting to use Chairo with happi to make a rest api which interfaces with seneca services.
I'm including both plugins with register:
Chairo decorates app, and req with an instance of seneca. However I'm not sure bagpipes is using the hapi request with my controller. req.seneca is undefined when I make a request to my controller. Not being familiar with hapi, shouldn't all registered plugins be available for use together?
The text was updated successfully, but these errors were encountered: