Challenge Overview
NodeJS application should get environment variables from ".env" file in DEV mode.
Project Background
Topcoder Project Service is a main backend service of the Topcode Connect is a client-facing application of Topcoder. We are trying to make the local setup of Topcoder Project Service as easy as possible. Currently, when someone wants to start Project Service locally, the next steps have to be done:
- we share on the forum values for environment variables AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_URL, AUTH0_AUDIENCE, AUTH0_PROXY_SERVER_URL
- the one who wants to start Project Service has to set them somehow in the terminal
- run the Project Service in dev mode using the command "npm run start:dev"
It's easy to forget to set the environment variables, so we would like to make this more automatic.
Technology Stack
-
Node
-
Nodemon
-
Babel
Code access
- Topcoder Project Service repo https://github.com/topcoder-platform/tc-project-service branch `develop`, commit `33bdb8a1463ec82171540f7c6f6465de99c7ebbe` or later.
- Config and references to local setup guides are provided on the forum.
Individual requirements
Environment variables AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_URL, AUTH0_AUDIENCE, AUTH0_PROXY_SERVER_URL should be automatically set when we start the Project Service locally using the command "npm run start:dev".
-
These values should come from the ".env" file in the root directory (example file provided on the forum).
-
Do not modify the source code of the application. We should only modify how the command "npm run start:dev" works, so there is no chance file ".env" is used in production.
-
NOTE: that ".env" should not be included in the repository. So when someone wants to run Project Service locally, he would need to create such a file locally using the values provided on the forum. But when the file is created "npm run start:dev" should use these values automatically.
There is a well-known way to do it using "dotenv" npm package. And it's preferable that we also use "dotenv" package. The only tricky moment to use it is that we in command "npm run start:dev" we use "nodemon" and "babel-node" so we have to somehow config "dotenv" to work in such case without modifying the source code of the application.
General requirements
-
The setup process must work on macOS and Linux operating systems.
-
Windows is not supported at the moment but we are going to support it soon, so don't introduce new places that wouldn't work on Windows.
-
DON’T include the values for environment variables AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_URL, AUTH0_AUDIENCE, AUTH0_PROXY_SERVER_URL inside the repository or git patch. These variables should be always configurable manually by setting environment variables.
If you have any questions or concerns, please, feel free to ask on the forum.
Final Submission Guidelines
Submit a zip file which would include:
-
Git patch with changes you’ve made to the code in our repository.
Additionally, the winner would be required to raise a pull request to the repository after the challenge is completed.