cds-snc / node-starter-app

Quick start application setup.... because you have to start somewhere.
MIT License
5 stars 3 forks source link

Simplify getRouteWithIndexByName using Array::findIndex #17

Closed jneen closed 5 years ago

jneen commented 5 years ago

At least one dev was confused by the implementation of this method - I've simplified it so that its intent is a bit clearer.

jneen commented 5 years ago

I should also note that the index is now guaranteed to be a number - I see a couple of places where we're doing some defensive coding in case it's not, and I'm not exactly sure why that would be.

timarney commented 5 years ago

Feel free to submit PRs for the other spots to clean things up + tests.

Moving pretty fast likely lots of little tweaks to be made.

For instance

The doRedirect middleware needs to get fixed up so it doesn't use "req.body.name"

That was one case where the "name" might not exist

const nextRoute = getNextRoute(req.body.name);