Effect-TS / effect

An ecosystem of tools to build robust applications in TypeScript
https://effect.website
MIT License
7.71k stars 245 forks source link

extend HttpApiEndpoint .setUrlParams to support arrays #3995

Open jessekelly881 opened 1 day ago

jessekelly881 commented 1 day ago

What is the problem this feature would solve?

setUrlParams currently only supports a struct of the form { _: string } but encoding an array in a url using multiple assignments to the same prop is common.

What is the feature you are proposing to solve the problem?

It would be nice if setUrlParams supported { _: string | string[] } encoded as ?x=1&x=2...

What alternatives have you considered?

No response

patroza commented 1 hour ago

@jessekelly881 wdym? https://github.com/Effect-TS/effect/blob/42c4ce6f8d8c7d847e97757650a8ad9419a829d7/packages/platform/src/UrlParams.ts#L23

jessekelly881 commented 1 hour ago

I'm talking about the method .setUrlParams method on the HttpApiEndpoint class. Sorry, I didn't realize that there was still a stand alone function as well. https://github.com/Effect-TS/effect/blob/main/packages%2Fplatform%2Fsrc%2FHttpApiEndpoint.ts#L159

It calls a ValidateUrlParams type fn that checks that the schema looks like Record<string, string> https://github.com/Effect-TS/effect/blob/main/packages%2Fplatform%2Fsrc%2FHttpApiEndpoint.ts#L541