BackendStack21 / fast-gateway

Fast-gateway is an easy to use Node.js API gateway framework built to handle large scale API traffic with great performance and scalability. Written with JavaScript, it is a framework for the masses!
MIT License
311 stars 35 forks source link

Query parameter serialization changes style #80

Closed sPaCeMoNk3yIam closed 2 years ago

sPaCeMoNk3yIam commented 2 years ago

When using a specific query parameter serialization style it might be this lib changes the serialization for the upstream request. https://github.com/BackendStack21/fast-gateway/blob/4a2ff7d02aedc3157413145040bc7fd115070660/index.js#L121

This actually stores the parsed query params to queryString rather than the original string. Then for 'http' proxy type's fast-proxy-lite uses it's default serialization, which is comma separated: https://github.com/BackendStack21/fast-proxy-lite/blob/eb9df39341a33591e2aee596d69e5aed8256561e/index.js#L141

Imho it'd be better to use the original query string - over the parsed one - to make sure no change happens. Otherwise, an easy option to specify the serialization style would be a good alternative - maybe in addition for a serialization callback (enum | function).

The above mentioned line of code could be changed to require('url').parse(req.url, false).query or require('url').parse(req.url, true).search - depending on if the leading ? needs to be included or not.

raoulus commented 2 years ago

👍