CirclesUBI / slimemold-service

Trust network indexing and transfer steps finding API for Circles
GNU Affero General Public License v3.0
1 stars 0 forks source link

Introduce ConfigModule #19

Closed adzialocha closed 3 years ago

adzialocha commented 3 years ago

This PR introduces an own implementation of ConfigModule and ConfigService instead of the one offered by NestJS. Using our own config implementation will make sure we always use our custom schema validation whenever we import the service.

adzialocha commented 3 years ago

I like we are validating everything. But, how can I see if the the validation is performed? I tried to run the tests, the lint, and the server with PORT=aaa in the .env file and I didn't see the any validation error message.

When I change PORT=aaa in .env and run npm start I see the following message:

Error: Missing environment variables: An instance of EnvironmentVariables has failed the validation:
 - property PORT has failed the following constraints: isNumber

Does it not work for you?

llunaCreixent commented 3 years ago

Yes! Now I see it. Perfect!

adzialocha commented 3 years ago

I've deleted your addition of npm start again from the README.md :sweat_smile: @llunaCreixent, just realized that the right way to do local development is to use npm run watch as already written in the README.md. npm start is only for production builds and only works AFTER running npm run build.

Both watch and start will check for .env validation though.

llunaCreixent commented 3 years ago

Alright, but I didn't see the validation error when npm run watch.

adzialocha commented 3 years ago

Alright, but I didn't see the validation error when npm run watch.

Interesting, for me this worked as well .. not sure how to troubleshoot this.