{"id":20215820,"url":"https://github.com/pallad-ts/app-env","last_synced_at":"2026-04-21T03:33:07.520Z","repository":{"id":57134906,"uuid":"297776946","full_name":"pallad-ts/app-env","owner":"pallad-ts","description":"Detect environment like: prod, test or more and adapt to it","archived":false,"fork":false,"pushed_at":"2025-05-04T10:39:33.000Z","size":1343,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T20:15:13.931Z","etag":null,"topics":["ci-environment","development-environment","environment","nodejs","production-environment","staging-environment","test-environment","typescript"],"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/pallad-ts.png","metadata":{"files":{"readme":"README.MD","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2020-09-22T21:30:51.000Z","updated_at":"2025-05-04T10:39:33.000Z","dependencies_parsed_at":"2025-05-25T20:49:14.438Z","dependency_job_id":null,"html_url":"https://github.com/pallad-ts/app-env","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pallad-ts/app-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallad-ts%2Fapp-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallad-ts%2Fapp-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallad-ts%2Fapp-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallad-ts%2Fapp-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pallad-ts","download_url":"https://codeload.github.com/pallad-ts/app-env/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallad-ts%2Fapp-env/sbom","scorecard":{"id":718371,"data":{"date":"2025-08-11","repo":{"name":"github.com/pallad-ts/app-env","commit":"77e50ae8ce27a434d277f7c701594d48c67968ec"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-xffm-g5w8-qvg7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T10:27:01.020Z","repository_id":57134906,"created_at":"2025-08-22T10:27:01.020Z","updated_at":"2025-08-22T10:27:01.020Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32075241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ci-environment","development-environment","environment","nodejs","production-environment","staging-environment","test-environment","typescript"],"created_at":"2024-11-14T06:24:46.551Z","updated_at":"2026-04-21T03:33:07.515Z","avatar_url":"https://github.com/pallad-ts.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003ch1\u003eapp-env 🕵️\u003c/h1\u003e\n\t\u003cp\u003eWhat environment are you in?\u003c/p\u003e\n\u003c/div\u003e\n\n---\n[![CircleCI](https://circleci.com/gh/pallad-ts/app-env/tree/master.svg?style=svg)](https://circleci.com/gh/pallad-ts/app-env/tree/master)\n[![npm version](https://badge.fury.io/js/@pallad%2Fapp-env.svg)](https://badge.fury.io/js/@pallad%2Fapp-env)\n[![Coverage Status](https://coveralls.io/repos/github/pallad-ts/app-env/badge.svg?branch=master)](https://coveralls.io/github/pallad-ts/app-env?branch=master)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n---\n\n![Example code](./assets/intro.png)\n\nLibrary to detect in which environment your app is working. Supports detection of following environments:\n\n- production\n- development\n- test\n- staging\n- ci\n- preview\n\nIf you need to support more environments see [non standard environments](#non-standard-environments)\n\nAllows to easy change of environments through env variables.\n\n# Features\n\n* 👷 Built with Typescript with full types support\n* 📝 Supports wider spectrum of environments than just `production` and `development`\n* 🔥 Provides builder to easily change configs/flags/switchers in type safe manner\n* 📝 Supports environment ID\n\n# Installation\n\n```shell\nnpm install @pallad/app-env\n```\n\n# When do I need it?\n\n* If you need to support more than 2 most common environments (production, development) in your app.\n* If you need to change app behavior, config, flags based on detected behavior\n* If you need an easy ability to change environment without affecting `NODE_ENV`\n* If you hate ugly `process.env.NODE_ENV` comparisons in your code\n\n# How is environment detected?\n\n`@pallad/app-env` detects environment based on available env variables.\n\n1. If `APP_ENV` env variable is supported environment name (case-insensitive) then use it, otherwise move to next step.\n2. If `NODE_ENV` env variable is supported environment name (case-insensitive) then use it, otherwise move to next step.\n3. If CI environment is detected then it is `ci`, otherwise move to next step.\n4. Fallback to `development`\n\nBased on that logic you can easily lib to use your desired environment by settings `APP_ENV` variable.\n\nRun process in `test` environment\n\n```shell\nAPP_ENV=test node some-process.js\n```\n\nRun process in `staging` environment. Note that `NODE_ENV` variable will be simply ignored.\n\n```shell\nAPP_ENV=staging NODE_ENV=development node some-process.js\n```\n\n# API\n\n## Name\n\n```typescript\nimport * as e from '@pallad/app-env';\n\ne.name; // 'test'\ne.env; // 'test'\n```\n\n## Flags\n\n```typescript\nimport * as e from '@pallad/app-env';\n\ne.isProduction;\ne.isDevelopment;\ne.isStaging;\ne.isTest;\ne.isCI;\ne.isPreview;\n```\n\n## Flag helpers\n\n```typescript\nimport * as e from '@pallad/app-env';\n\ne.is('production'); // true for production\ne.isEnv('production'); // same as above\n\ne.is('production', 'staging'); // true for production or staging\ne.isEnv('production', 'staging'); // same as above\n```\n\n## Value helpers\n\n```typescript\nimport * as e from '@pallad/app-env';\n\ne.forEnv('production')('foo'); // returns \"foo\" for production, undefined otherwise\ne.forEnv('production')('foo', 'bar'); // returns \"foo\" for production, \"bar\" otherwise\n\ne.forEnv('production', 'staging')('foo'); // returns \"foo\" for production or staging, undefined otherwise\ne.forEnv('production', 'staging')('foo', 'bar'); // returns \"foo\" for production or staging, \"bar\" otherwise\n\ne.forDevelopment('foo'); // returns \"foo\" for development, undefined otherwise\ne.forDevelopment('foo', 'bar'); // returns \"foo\" for development, \"bar\" otherwise\n\ne.forCI('foo')\ne.forStaging('foo')\ne.forTest('foo')\ne.forProduction('foo')\n```\n\n## Advanced value builder\n\nUltimate helper of all helpers. Extends [@pallad/builder](https://github.com/pallad-ts/builder).\n\n```typescript\nimport * as e from '@pallad/app-env';\n\nconst value = e.build()\n\t.forDevelopment('foo')\n\t.forStaging('bar')\n\t.forEnv(['production', 'test'], 'baz')\n\t.getOrDefault('wtf?'); // or just .get() to get value without default\n```\n\nNote that the order of chaining is important\n\n```typescript\nconst value = e.build()\n\t.forDevelopment('foo')\n\t.forStaging('bar')\n\t.forEnv(['development', 'test'], 'baz')\n\t.get(); // you'll get \"foo\" (not \"baz\") for development since it was first evaluated rule\n```\n\n# Non standard environments\n\nWhile library by default supports most of commonly known environment names sometimes you might have special environments\nthat are not covered.\n\nFor such cases you can create your own factory with custom environment names.\n\n```typescript\nimport {Factory} from '@pallad/app-env';\n\nconst factory = new Factory({\n\tenvName: ['e2e', 'eu_region', 'production', 'staging']\n});\nconst info = factory.create('e2e');\n\ninfo.isEnv('e2e') // true\ninfo.isProduction // false\n\nfactory.getEnvNameFromProcess(); // will resolve to custom env name\n```\n\n# Environment ID\n\nThere are cases when you need to identify environment in a more unique way.\nFor example preview or test environment created for pull request requires unique ID to identify it (might be PR number).\n\nFor that cases getting environment ID is possible through `id` property or `factory.getEnvIdFromProcess()` method.\n\nEnvironment ID can be set through `APP_ENV_ID` env variable or custom ones (configured through\nFactoryConfig.envIdEnvKeys).\n\n```typescript\n\nimport {id, name} from '@pallad/app-env';\n\nid; // 'PR-1234'\nname; // 'preview'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpallad-ts%2Fapp-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpallad-ts%2Fapp-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpallad-ts%2Fapp-env/lists"}