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

Correctly set NODE_ENV #903

Merged
merged 3 commits into from Aug 25, 2022
Merged

Correctly set NODE_ENV #903

merged 3 commits into from Aug 25, 2022

Conversation

Cruikshanks
Copy link
Member

DEFRA/water-abstraction-team#43

We are currently using NODE_ENV incorrectly; we set it to be the name of the specific environment (eg. local, qa etc.) when it should be more like the type of environment (e.g. is it a dev environment, a production environment, etc.)

This means that tools like pm2 aren't correctly picking up that we are running in a dev-like or prod-like environment and configuring accordingly.

We, therefore, change how we use NODE_ENV to be the type of environment, with a separate ENVIRONMENT env var to set the actual environment (eg. tst, pre etc.)

DEFRA/water-abstraction-team#43

We are currently using `NODE_ENV` incorrectly; we set it to be the name of the specific environment (eg. `local`, `qa` etc.) when it should be more like the _type_ of environment (e.g. is it a dev environment, a production environment, etc.)

This means that tools like pm2 aren't correctly picking up that we are running in a dev-like or prod-like environment and configuring accordingly.

We, therefore, change how we use `NODE_ENV` to be the type of environment, with a separate `ENVIRONMENT` env var to set the actual environment (eg. `tst`, `pre` etc.)
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Aug 25, 2022
@Cruikshanks Cruikshanks self-assigned this Aug 25, 2022
This is the pattern we're using throughout the projects now using `ENVIRONMENT` to determine whether we are in `prd` or not.

We also drop requiring dotenv directly. We've not needed it in other config.js files and we're pretty certain requiring it in the root index.js is all you need.
Looks like we were giving our local dev environments a boost when it came to connecting to PostgreSQL. We don't agree with making adjustments like this for local development. Plus, based on what we've seen so far we're not confident we should be playing with the default Postgres connection config at all.

For now, we'll settle on just using the same config no matter the environment and leave changes to PG config to a wider review of the projects.
@Cruikshanks Cruikshanks marked this pull request as ready for review August 25, 2022 19:40
@Cruikshanks Cruikshanks merged commit b1d3bd6 into main Aug 25, 2022
@Cruikshanks Cruikshanks deleted the correctly-set-node-env branch August 25, 2022 19:41
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
1 participant