{"id":26871324,"url":"https://github.com/codeadamca/nodejs-env","last_synced_at":"2025-07-27T02:33:57.096Z","repository":{"id":270631270,"uuid":"910967910","full_name":"codeadamca/nodejs-env","owner":"codeadamca","description":"A basic function to load variables from a .env file. ","archived":false,"fork":false,"pushed_at":"2025-01-26T21:17:08.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T07:19:04.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeadamca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-01T23:41:59.000Z","updated_at":"2025-01-26T21:17:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f64d69e8-e8b1-4a84-af33-c25edf807bbe","html_url":"https://github.com/codeadamca/nodejs-env","commit_stats":null,"previous_names":["codeadamca/nodejs-env"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codeadamca/nodejs-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fnodejs-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fnodejs-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fnodejs-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fnodejs-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeadamca","download_url":"https://codeload.github.com/codeadamca/nodejs-env/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeadamca%2Fnodejs-env/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267288909,"owners_count":24064725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-31T07:19:07.374Z","updated_at":"2025-07-27T02:33:57.067Z","avatar_url":"https://github.com/codeadamca.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hiding Node.js Environment Varaibles\n\nA basic vanilla Node.js script to load variables from an .env file. Run the script using a regular Node.js starting command `node app.js` and add a flag to include environment variabl;es `--end-file=.env`.\n\n1. Create a file called `.env` and place it in your project folder.\n\n2. Put your actual database credentials and API keys in your `.env``file:\n    \n    ```php\n    DB_HOST=\u003cDB_HOST\u003e\n    DB_DATABASE=\u003cDB_DATABASE\u003e\n    DB_USERNAME=\u003cDB_USERNAME\u003e\n    DB_PASSWORD=\u003cDB_PASSWORD\u003e\n    \n    API_SECRET=real_api_key\n    ```\n\n3. Create a second copy of your `.env` file and name it `.env.sample`. Use this file to provide instructions to the next programmer using your project code:\n    \n    ```php\n    DB_HOST=localhost\n    DB_DATABASE=database\n    DB_USERNAME=username\n    DB_PASSWORD=password\n    \n    API_SECRET=api_key\n    ```\n\n4. Make sure your GitHub repo does not include the file named `.env`. In your `.gitignore` file add:\n    \n    ```\n    .env\n    ```\n\n\u003e [!Note]\n\u003e I have excluded this step in this repo so you can view both the `.env` and `.env.sample` files. \n\n5. Start the Node.js app with the `.env` file:\n\n    ```\n    node --end-file=.env app.js\n    ```\n\n---\n\n## Project Stack\n\nThis project uses [Node.js](https://nodejs.org/).\n\n\u003cimg src=\"https://console.codeadam.ca/api/image/nodejs\" width=\"60\"\u003e \n\n---\n\n## Repo Resources\n\n- [Node.js](https://nodejs.org/)\n- [propcess.env](https://nodejs.org/api/process.html#processenv)\n\n\u003cbr\u003e\n\u003ca href=\"https://codeadam.ca\"\u003e\n\u003cimg src=\"https://cdn.codeadam.ca/images@1.0.0/codeadam-logo-coloured-horizontal.png\" width=\"200\"\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Fnodejs-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeadamca%2Fnodejs-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeadamca%2Fnodejs-env/lists"}