Fix serverSync to use apiProxy logic in the same way the clientSync does#256
Fix serverSync to use apiProxy logic in the same way the clientSync does#256lxanders wants to merge 8 commits intorendrjs:masterfrom
Conversation
the syncer now uses the apiProx instead of the data adapter
There was a problem hiding this comment.
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
serverSyncmethod insyncer.jsused thedataAdapterto request data from an api host. This is a problem as e.g. thex-forward-forheader is only set in theapiProxy. TheserverSyncmethod should work the same way as theclientSyncmethod which already uses theapiProxy.We extracted the proxy request logic to a reusable method
proxyRequeststored in theapiProxyMiddleware. Additionally we added theresobject to the globalappobject in the same way thereqobject is already being added to it, to allow a customapiProxymaking use of theresobject.One additional advantage would be the decoupling of the
dataAdapterfrom thesyncerwhich e.g. makes it simple to implement support for multipledataAdapters (e.g. for REST and for SOAP).CC: @c089, @selaux, @lo1tuma