{"id":16515158,"url":"https://github.com/jacobwgillespie/the-environment","last_synced_at":"2025-07-05T18:02:06.634Z","repository":{"id":38339100,"uuid":"446262143","full_name":"jacobwgillespie/the-environment","owner":"jacobwgillespie","description":"🌱 Simple Node.js package for environment variables","archived":false,"fork":false,"pushed_at":"2024-09-19T18:17:36.000Z","size":101,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T11:35:01.456Z","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/jacobwgillespie.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":"2022-01-10T02:56:31.000Z","updated_at":"2024-05-07T19:21:34.000Z","dependencies_parsed_at":"2023-02-08T08:31:24.407Z","dependency_job_id":"c19dd014-a547-4d9a-8520-d2c154b3f67b","html_url":"https://github.com/jacobwgillespie/the-environment","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.25,"last_synced_commit":"dda547844d9bdda082e62dacf4c1fc167410caf3"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwgillespie%2Fthe-environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwgillespie%2Fthe-environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwgillespie%2Fthe-environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwgillespie%2Fthe-environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobwgillespie","download_url":"https://codeload.github.com/jacobwgillespie/the-environment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238597388,"owners_count":19498396,"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-10-11T16:15:47.604Z","updated_at":"2025-02-13T04:32:59.154Z","avatar_url":"https://github.com/jacobwgillespie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌱 the-environment\n\n[![CI](https://github.com/jacobwgillespie/the-environment/actions/workflows/ci.yml/badge.svg)](https://github.com/jacobwgillespie/the-environment/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/dm/the-environment.svg)](https://www.npmjs.com/package/the-environment)\n[![npm](https://img.shields.io/npm/v/the-environment.svg)](https://www.npmjs.com/package/the-environment)\n![Powered by TypeScript](https://img.shields.io/badge/powered%20by-typescript-blue.svg)\n\nSimple Node.js package for reading environment variables, TypeScript support included.\n\n## Installation\n\n```\n$ pnpm add the-environment\n$ yarn add the-environment\n$ npm install the-environment\n```\n\n## Usage\n\nThe `optional` import mirrors the behavior of `process.env`, returning either the string value or `undefined` if the variable is unset:\n\n```typescript\nimport {optional} from 'the-environment'\n\n// Fetch an optional environment variable:\nconsole.log(optional.NODE_ENV)\n```\n\nThe `required` import either returns the string value or throws a `MissingEnvironmentVariableError` if the variable is unset:\n\n```typescript\nimport {required, MissingEnvironmentVariableError} from 'the-environment'\n\n// Fetch a required environment variable, throw an error if not present:\nconsole.log(required.NODE_ENV)\n\ntry {\n  console.log(required.DOES_NOT_EXIST)\n} catch (e) {\n  if (e instanceof MissingEnvironmentVariableError) {\n    //-\u003e Missing required environment variable: DOES_NOT_EXIST\n    console.log(e.message)\n\n    //-\u003e DOES_NOT_EXIST\n    console.log(e.variable)\n  }\n}\n```\n\nIf you'd like to import both `optional` and `required`, you can also use `import * as` to name it `env`:\n\n```typescript\nimport * as env from 'the-environment'\n\nconsole.log(env.optional.NODE_ENV)\nconsole.log(env.required.NODE_ENV)\n```\n\n## License\n\nMIT License, see `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwgillespie%2Fthe-environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobwgillespie%2Fthe-environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwgillespie%2Fthe-environment/lists"}