phetsims / rosetta

PhET's Simulation Translation Utility
MIT License
3 stars 1 forks source link

Cast API query parameter string booleans to real booleans #391

Closed liammulh closed 1 year ago

liammulh commented 1 year ago

Some of the API routes expect query parameters to be present. For example, see the function associated with the simNamesAndTitles API route:

https://github.com/phetsims/rosetta/blob/b1e931df1c9a2cb225da94ce423c65695a90fc52/src/server/translationApi/api/simNamesAndTitles.js#L19-L22

The req.query.isTeamMember is returned as a string. We should cast it (and other API query parameter string booleans) to a real boolean so that it doesn't trip anyone up in the future. This will also involve changing the parameters to the functions we call using the API query parameter string booleans.

To do this comprehensively, we should search across the project for instances of req.query.*. We should note where these variables are being used, cast them to booleans in the API callback functions, and modify the functions that use these variable so that they expect booleans rather than string booleans.

liammulh commented 1 year ago

As of https://github.com/phetsims/rosetta/commit/a9a31d6b0af7cdc79b4aa3b370a792b607ae9313, I believe this is done awaiting deploy.

liammulh commented 1 year ago

This is deployed.

phet-dev commented 1 year ago

Reopening because there is a TODO marked for this issue.