These are chat archives for jdubray/sam

6th
Oct 2016
devin ivy
@devinivy
Oct 06 2016 03:34
@jdubray i would highly suggest using a callback!
Jean-Jacques Dubray
@jdubray
Oct 06 2016 03:52
@devinivy I don't have a choice, that's how express-http-proxy works you have to provide a synchronous filter function. Does Hapi.js have a proxy capability?
@inrix-vincent-jo thank you Vincent, that's helpful, I had looked at async (the library is currently downloaded 39M times per month!!) but not directly to async/await because it needed transpiling. I'll check if I can adapt your code to the async library.
Edward Mulraney
@edmulraney
Oct 06 2016 09:49
@jdubray why dont you just make filter asynchronous? you can do that without async/await
oh i see. you're saying express-http-proxy doesnt allow you
Jean-Jacques Dubray
@jdubray
Oct 06 2016 10:26
yes, that's the problem. The easiest is probably to modify http-proxy, in the latest version they have started to convert these methods to an async model
devin ivy
@devinivy
Oct 06 2016 13:24
yeah, there's no way to do quite what you're talking about– you'll need to hack around the limitation or hack http-proxy!
hapi does have an official proxy plugin called h2o2
Vincent Jo
@inrix-vincent-jo
Oct 06 2016 17:02
yea, I just looked at the documentation for express-http-proxy right now and like everyone already said it seems like the filter function cannot yet return a promise.
:(
Vincent Jo
@inrix-vincent-jo
Oct 06 2016 17:09
I'm curious to know what kind of call is being made inside of the filter function?
Jean-Jacques Dubray
@jdubray
Oct 06 2016 17:14
Filter is used for deciding whether you "filter" the request to the back-end. I made some progress in caching my blog to S3 and I was trying to serve the cached content from S3. If the resource is in S3 I should return false, otherwise I should return true and return the S3 resources. Unfortunately, the return value comes too late and the S3 response collides with the back-end response.