Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast API query parameter string booleans to real booleans #391

Closed
Tracked by #407
liammulh opened this issue Apr 7, 2023 · 3 comments
Closed
Tracked by #407

Cast API query parameter string booleans to real booleans #391

liammulh opened this issue Apr 7, 2023 · 3 comments

Comments

@liammulh
Copy link
Member

liammulh commented Apr 7, 2023

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

const simNamesAndTitles = async ( req, res ) => {
logger.info( 'responding with sim names and titles' );
res.json( getSimNamesAndTitles( await getSimMetadata(), req.query.isTeamMember ) );
};

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 added a commit that referenced this issue May 5, 2023
@liammulh liammulh mentioned this issue May 23, 2023
14 tasks
liammulh added a commit that referenced this issue May 24, 2023
@liammulh
Copy link
Member Author

As of a9a31d6, I believe this is done awaiting deploy.

@liammulh
Copy link
Member Author

This is deployed.

@phet-dev phet-dev reopened this May 25, 2023
@phet-dev
Copy link
Contributor

Reopening because there is a TODO marked for this issue.

liammulh added a commit that referenced this issue May 27, 2023
@liammulh liammulh changed the title refactor: cast API query parameter string booleans to real booleans Cast API query parameter string booleans to real booleans May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants