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

Bail earlier if in maintenance mode #71

Open
leggsimon opened this issue Jun 5, 2018 · 0 comments
Open

Bail earlier if in maintenance mode #71

leggsimon opened this issue Jun 5, 2018 · 0 comments

Comments

@leggsimon
Copy link
Contributor

In the middleware chain in ./server/app.js we check if the maintenance mode flag is on quite early but send a 503 to the user as the last step before hitting any of the defined routes. Between checking the flag and sending the 503 we have 10 other pieces of middleware for various things, 6 of them check the state of that flag and just call next() if it's on, 1 of them checks but some of the code is run regardless of the flag’s state, and 3 seem to not care about it’s state.

I wonder whether we should bail earl and send the 503 straight away? Unless any of the code that doesn’t check really needs to run regardless, I propose combining the ./server/middleware/route-maintenance-mode code and ./server/middleware/flag-maintenance-mode code and sending the 503 straight away not bothering to run any of it.

Middleware that checks the flag and does nothing if true:

  • ./server/middleware/db
  • ./server/middleware/expedite-user-auth
  • ./server/middleware/get-user-access-auth-token
  • ./server/middleware/get-user-profile
  • ./server/middleware/get-contract-by-id
  • ./server/middleware/check-if-new-syndication-user

Middleware that checks the flag but has other code that doesn’t check:

  • ./server/middleware/is-syndication-user

Middleware that doesn’t check at all:

  • ./server/middleware/decode-session
  • ./server/middleware/masquerade
  • ./server/middleware/get-syndication-licence-for-user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant