Closed adzialocha closed 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?
Yes! Now I see it. Perfect!
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.
Alright, but I didn't see the validation error when npm run watch
.
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.
This PR introduces an own implementation of
ConfigModule
andConfigService
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.