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

Improve configuration process #28

Merged
merged 23 commits into from
Oct 27, 2022
Merged

Conversation

ivanzy
Copy link
Contributor

@ivanzy ivanzy commented Oct 20, 2022

This PR implements 4 features mentioned in the issue #25 . Namely:

  • Refactoring code to have a structured config model
  • Support different development environments: the NODE_ENV variable defines which .env file should be loaded from the envs directory.
  • Hooks on package.json: the prefix NODE_ENV=environment was added in the run:dev and run:prod
  • Review and check the defaults: A class was created that holds the default values of al configs utilized in Zion.

@ivanzy ivanzy requested review from hyperloris and relu91 October 20, 2022 15:45
@relu91 relu91 changed the title 25 improve configuration process Improve configuration process Oct 20, 2022
.eslintrc.js Outdated Show resolved Hide resolved
Copy link
Contributor

@hyperloris hyperloris left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!
There are two minor issues that need to be addressed before merging the PR:

  1. In src/config/interfaces you are using a lowerCamelCase convention for file names. In this repository we are adopting the same convention used by NestJS. You can read more in the CONTRIBUTING document.
  2. The env files are inside src/config/env. I suggest moving them to the root of the repository. To be more precise, I would move the .env file to the root level and test.env inside the test folder so that the "testing block" is treated as a separate application.

@ivanzy
Copy link
Contributor Author

ivanzy commented Oct 26, 2022

I do not agree on the second point. The idea is that the env variables should not be scatter over different directories. I know that if we have only a template .env and a test.env this would not be a problem, but we envision multiple possible enviroments, such as production, staging and more. Then, Where should we place the .env?

The use of a envs directory is not so rare in NodeJS systems, they do it in those tutorials: https://blog.devgenius.io/environment-variables-in-nest-js-b989bb0370bf and https://dev.to/pitops/managing-multiple-environments-in-nestjs-71l

@relu91
Copy link
Contributor

relu91 commented Oct 26, 2022

I do not agree on the second point. The idea is that the env variables should not be scatter over different directories. I know that if we have only a template .env and a test.env this would not be a problem, but we envision multiple possible enviroments, such as production, staging and more. Then, Where should we place the .env?

I'm on call right now, and I might extend this answer later but I would simply say: in the root folder. The test.env is just a special case for our integration test. It is not a real testing environment (like it might be a server where we do a couple of benchmarks or other validations). If that still bothers you (tbh I don't like exceptions either) I would propose the following:

  • both env files in the root folder
  • both env files inside a /config folder

Copy link
Contributor

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Can you rename config interfaces from <name>.ts to <name>.config.ts, I think config word in this case specifies the scope of the file content.

@ivanzy
Copy link
Contributor Author

ivanzy commented Oct 26, 2022

I addressed both the requested changes in the last commits:

  • config interfaces were renamed to *.config.ts
  • .envs files are in the root

@hyperloris hyperloris merged commit 5eca02b into main Oct 27, 2022
@relu91 relu91 mentioned this pull request Oct 27, 2022
6 tasks
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

Successfully merging this pull request may close these issues.

3 participants