{"id":21275243,"url":"https://github.com/geisonjr/envfy","last_synced_at":"2025-06-21T09:07:02.268Z","repository":{"id":231390772,"uuid":"763104190","full_name":"GeisonJr/envfy","owner":"GeisonJr","description":"Envfy is a versatile and lightweight library for Node.js that simplifies environment variables.","archived":false,"fork":false,"pushed_at":"2024-05-09T21:33:16.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T09:06:45.185Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeisonJr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-02-25T15:15:46.000Z","updated_at":"2024-08-25T21:00:53.000Z","dependencies_parsed_at":"2024-04-04T03:14:59.646Z","dependency_job_id":"3a03e55d-bdce-4211-9368-c238989fafb9","html_url":"https://github.com/GeisonJr/envfy","commit_stats":null,"previous_names":["geisonjr/envfy","geisonjr/env"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GeisonJr/envfy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeisonJr%2Fenvfy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeisonJr%2Fenvfy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeisonJr%2Fenvfy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeisonJr%2Fenvfy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeisonJr","download_url":"https://codeload.github.com/GeisonJr/envfy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeisonJr%2Fenvfy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261095310,"owners_count":23108784,"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","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":"2024-11-21T09:29:02.774Z","updated_at":"2025-06-21T09:06:57.257Z","avatar_url":"https://github.com/GeisonJr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\r\n  \u003ca href=\"https://geison.dev/\"\u003e\r\n    \u003cimg width=\"100\" src=\"https://geison.dev/assets/icons/logo.svg\" alt=\"Logo\" /\u003e\r\n  \u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\n\u003ch1 align=\"center\"\u003e\r\n\tEnvironment Variables Library\r\n\u003c/h1\u003e\r\n\u003cdiv align=\"center\"\u003e\r\n\r\nEasy to use, fast and lightweight library for Node.js.\r\n\r\n\u003ca\u003e\r\n\t\u003cimg src=\"https://img.shields.io/github/license/geisonjr/envfy?style=flat\" alt=\"MIT Licence\" /\u003e\r\n\u003c/a\u003e\r\n\u003ca href=\"https://www.npmjs.com/package/@geisonjr/envfy\"\u003e\r\n\t\u003cimg src=\"https://img.shields.io/npm/v/@geisonjr/envfy?style=flat-square\" alt=\"NPM version\" /\u003e\r\n\u003c/a\u003e\r\n\u003ca href=\"https://www.npmjs.com/package/@geisonjr/envfy\"\u003e\r\n\t\u003cimg src=\"https://img.shields.io/npm/dt/@geisonjr/envfy?style=flat-square\" alt=\"NPM downloads\" /\u003e\r\n\u003c/a\u003e\r\n\u003c/div\u003e\r\n\r\n\u003e [!WARNING]\r\n\u003e This project is under development and is not yet ready for use.\r\n\r\n## 🌱 Overview\r\n\r\nThe `.env` files are used to define environment variables for the project. The following files are used to manage configurations for different environments, such as development, testing, and production.\r\n\r\nThis structure enables a clear and organized approach to managing configurations, making it easier to customize settings for specific environments while maintaining a consistent setup for shared configurations\r\n\r\n## ✨ Features\r\n\r\n- [x] `process.env` variables\r\n- [x] `.env` and `.env.local` files\r\n- [x] `.env.${NODE_ENV}` and `.env.${NODE_ENV}.local` files\r\n- [x] Default, required and strict values\r\n- [x] Get value as array, boolean, number, string\r\n- [ ] Get value as date, object, url\r\n\r\n## 🚀 Tecnologies\r\n\r\nThe following tools were used in the construction of the project:\r\n\r\n- [Jest](https://jestjs.io/)\r\n- [Node.js](https://nodejs.org/en/)\r\n- [TypeScript](https://www.typescriptlang.org/)\r\n\r\n## 📦 Install\r\n\r\nUse the package manager [npm](https://docs.npmjs.com/),\r\n[yarn](https://classic.yarnpkg.com/lang/en/docs/).\r\n\r\n```bash\r\nnpm install @geisonjr/envfy\r\n```\r\n\r\n```bash\r\nyarn add @geisonjr/envfy\r\n```\r\n\r\n## 📋 Environment Files\r\n\r\n\u003e [!TIP]\r\n\u003e Both `.env` and `.env.local` files are loaded across all environments, providing a foundation for common configurations.\r\n\r\n\u003e [!IMPORTANT]\r\n\u003e These base configuration files reside in the root of the project.\r\n\r\n\u003e [!IMPORTANT]\r\n\u003e The prority of the environment variables is as follows:\r\n\u003e\r\n\u003e 1. `process.env` - default environment variables from the `OS`\r\n\u003e 2. `.env` - overrides `process.env`\r\n\u003e 3. `.env.local` - overrides `.env`\r\n\u003e 4. `.env.${NODE_ENV}` - overrides `.env.local`\r\n\u003e 5. `.env.${NODE_ENV}.local` - overrides `.env.${NODE_ENV}`\r\n\r\n### Base Files\r\n\r\n`.env`: Default environment variables.\r\n\r\n### Environment-Specific Files\r\n\r\nThe `.env*` files are selected based on the `NODE_ENV` environment variable, allowing tailored configurations for different deployment scenarios.\r\n\r\n`.env.${NODE_ENV}`: Environment-specific settings.\r\n\r\n#### Example\r\n\r\nIn the following example, the `.env.development` file is used to define environment variables for the development environment when the `NODE_ENV` environment variable is set to `development`.\r\n\r\n```.env\r\nNODE_ENV=development\r\n```\r\n\r\n```.env\r\n# .env.development\r\nENV_VAR_STRING=development-value\r\nENV_VAR_NUMBER=456\r\n```\r\n\r\n### Local Overrides\r\n\r\nThe `.env*.local` files are used to override configurations for local development, providing a way to customize settings without affecting the shared configurations.\r\n\r\n\u003e [!CAUTION]\r\n\u003e The `.env*.local` files are not committed to the version control system, as they are intended for local overrides. This practice ensures that the local environment settings do not interfere with the shared configurations.\r\n\r\n## 🏗️ Usage\r\n\r\n### Use environment variables directly from `process.env`\r\n\r\nCreate a `.env` file in the root of your project and add your environment variables.\r\n\r\n```.env\r\nENV_VAR_STRING=my-value // Can also use double quotes\r\nENV_VAR_NUMBER=123 // Can also use floating point numbers\r\nENV_VAR_BOOLEAN=true // \"true\", \"yes\", \"y\", \"1\", \"on\" are considered true\r\n```\r\n\r\n\u003e [!TIP]\r\n\u003e The following types are supported:\r\n\u003e\r\n\u003e - `array` - Can also use double quotes\r\n\u003e   - `1;2;3` or `\"1;2;3\"`\r\n\u003e - `boolean` - Can also use double quotes, Case insensitive\r\n\u003e   - Truthy: `true`, `yes`, `y`, `1`, `on`.\r\n\u003e   - Falsy: `false`, `no`, `n`, `0`, `off`.\r\n\u003e - `number` - Can also use double quotes\r\n\u003e   - `123`\r\n\u003e   - `123,456.789`\r\n\u003e - `string` - Can also use double quotes\r\n\u003e   - `my-value` or `\"my-value\"`\r\n\r\nImport the package in your code and use the environment variables.\r\n\r\n```typescript\r\nimport '@geisonjr/envfy/config'\r\n\r\n// Environment variables are now available in process.env\r\nprocess.env.ENV_VAR_STRING // 'my-value'\r\nprocess.env.ENV_VAR_NUMBER // '123'\r\nprocess.env.ENV_VAR_BOOLEAN // 'true'\r\n```\r\n\r\n### How use the `Env` class\r\n\r\n```typescript\r\nimport * as envfy from '@geisonjr/envfy'\r\n\r\n// Get value as boolean\r\nenvfy.boolean('ENV_VAR_BOOLEAN') // true\r\n// Get value as number\r\nenvfy.number('ENV_VAR_NUMBER') // 123\r\n// Get value as string\r\nenvfy.string('ENV_VAR_STRING') // 'my-value'\r\n```\r\n\r\n### How use default values\r\n\r\n```typescript\r\nimport * as envfy from '@geisonjr/envfy'\r\n\r\n// Get value as boolean with default value\r\nenvfy.boolean('ENV_VAR_NOT_EXISTS', true) // true\r\n// Get value as number with default value\r\nenvfy.number('ENV_VAR_NOT_EXISTS', 123.45) // 123.45\r\n// Get value as string with default value\r\nenvfy.string('ENV_VAR_NOT_EXISTS', 'default-value') // 'default-value'\r\n```\r\n\r\n## 📋 License\r\n\r\nThis project is under the\r\n[MIT License](https://github.com/geisonjr/envfy/blob/master/LICENSE)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeisonjr%2Fenvfy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeisonjr%2Fenvfy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeisonjr%2Fenvfy/lists"}