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

Add pre back into protected environments #716

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/WATER-4351

The project comes with an inbuilt mechanism to configure routes to not be available in protected environments, for example, production.

You can see this in app/routes/data.routes.js. Both /data/seed and /data/tear-down are configured to be excludeFromProd.

How this works is during startup our app/plugins/router.plugin.js calls app/services/plugins/filter-routes.service.js which handles filtering out those routes that should not be added when running in a protected environment.

To be honest, excludeFromProd is a bad name because it could be any environment we add to this

function _protectedEnvironment (environment) {
  return ['prd'].includes(environment)
}

When this was first implemented pre was included so we could confirm routes were not available before shipping to production. However, in Create endpoint to generate fake data we took it out so we could get this fake data generator to work. It needed to be in pre because it generated data based on real bill runs.

Clearly, we weren't on the ball because we didn't even bother to update the comments which still exist

 * So, we use this service to ensure any endpoint that is still being worked on is not available when the API is
 * running in production. We also include pre-production in our protected environments so we can test and ensure
 * an endpoint does not get registered as part of our release testing and sign-off.

Since that time the fake data generator is no more and we need to be able to test again that routes (and therefore pages) are not accessible in production. Hence, we need to add pre back into our list of protected environments.

https://eaflood.atlassian.net/browse/WATER-4351

The project comes with an inbuilt mechanism to configure routes to not be available in protected environments, for example, production.

You can see this in `app/routes/data.routes.js`. Both `/data/seed` and `/data/tear-down` are configured to be `excludeFromProd`.

How this works is during startup our `app/plugins/router.plugin.js` calls `app/services/plugins/filter-routes.service.js` which handles filtering out those routes that should not be added when running in a protected environment.

To be honest, `excludeFromProd` is a bad name because it could be any environment we add to this

```javascript
function _protectedEnvironment (environment) {
  return ['prd'].includes(environment)
}
```

When this was first implemented `pre` was included so we could confirm routes were not available prior to shipping to production. However, in [Create endpoint to generate fake data](#347) we took it out so we could get this fake data generator to work. It needed to be in `pre` because it generated data based on real bill runs.

Clearly we weren't on the ball because we didn't even bother to update the comments which still exist

```javascript
 * So, we use this service to ensure any endpoint that is still being worked on is not available when the API is
 * running in production. We also include pre-production in our protected environments so we can test and ensure
 * an endpoint does not get registered as part of our release testing and sign-off.
```

Since that time the fake data generator is no more and we need to be able to test again that routes (and therefore pages) are not accessible in production. Hence, we need to add `pre` back into our list of protected environments.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Feb 8, 2024
@Cruikshanks Cruikshanks self-assigned this Feb 8, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review February 8, 2024 10:01
@Cruikshanks
Copy link
Member Author

Just added @Beckyrose200 and @rvsiyad as reviewers as this is connected to their work so they need to know about it. Hence the description is 1000x larger than the change! 😬

Copy link
Contributor

@rvsiyad rvsiyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruikshanks Cruikshanks merged commit ed5f7e1 into main Feb 8, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the add-pre-to-protected-environments branch February 8, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants