-
Notifications
You must be signed in to change notification settings - Fork 312
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
Fix serverSync to use apiProxy logic in the same way the clientSync does #256
base: master
Are you sure you want to change the base?
Conversation
the syncer now uses the apiProx instead of the data adapter
@@ -24,6 +24,7 @@ module.exports = function(appAttributes, options) { | |||
* This will only be accessible on the server. | |||
*/ | |||
req: req, | |||
res: res, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't strictly necessary because req
and res
have references to each other -- i.e. you could do this.app.req.res
Thanks for pointing this out. I think it might make more sense to just move the |
I'm with Spike on this one: We've been mixing responsibilities in the I'm not sure if moving to |
After discussing with c089 I'm with you now. The problem itself is still valid though so I'm not closing the pull request for now (it would have been a good idea to describe the problem in an issue and have the discussion there - next time). |
Formerly the
serverSync
method insyncer.js
used thedataAdapter
to request data from an api host. This is a problem as e.g. thex-forward-for
header is only set in theapiProxy
. TheserverSync
method should work the same way as theclientSync
method which already uses theapiProxy
.We extracted the proxy request logic to a reusable method
proxyRequest
stored in theapiProxyMiddleware
. Additionally we added theres
object to the globalapp
object in the same way thereq
object is already being added to it, to allow a customapiProxy
making use of theres
object.One additional advantage would be the decoupling of the
dataAdapter
from thesyncer
which e.g. makes it simple to implement support for multipledataAdapter
s (e.g. for REST and for SOAP).CC: @c089, @selaux, @lo1tuma