{"id":31904833,"url":"https://github.com/pokatomnik/deno-environment","last_synced_at":"2026-05-18T03:07:10.362Z","repository":{"id":53566568,"uuid":"350763000","full_name":"pokatomnik/deno-environment","owner":"pokatomnik","description":"Friendly wrapper for Deno env","archived":false,"fork":false,"pushed_at":"2021-03-23T21:52:33.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-16T18:10:00.738Z","etag":null,"topics":["deno","env","environment-variables","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/pokatomnik.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}},"created_at":"2021-03-23T15:28:13.000Z","updated_at":"2021-06-26T03:34:05.000Z","dependencies_parsed_at":"2022-09-09T07:10:10.595Z","dependency_job_id":null,"html_url":"https://github.com/pokatomnik/deno-environment","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pokatomnik/deno-environment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fdeno-environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fdeno-environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fdeno-environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fdeno-environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokatomnik","download_url":"https://codeload.github.com/pokatomnik/deno-environment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fdeno-environment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"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":["deno","env","environment-variables","typescript"],"created_at":"2025-10-13T13:59:29.010Z","updated_at":"2026-05-18T03:07:10.328Z","avatar_url":"https://github.com/pokatomnik.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deno-environment\n\n[Deno](https://deno.land/) package for environment variables management.\n\nCurrently, Deno exposes environment variables through `Deno.env`. This package is for converting environment variables to expected types.\n\n## Exports are:\n\n### `StringValue`\n\nTypescript [string type](https://www.typescriptlang.org/docs/handbook/basic-types.html#string). It checks if the environment value exists and does nothing with It.\n\n### `NumberValue`\n\nTypescript [number type](https://www.typescriptlang.org/docs/handbook/basic-types.html#number). Converts env value to number.\n\n### `IntValue`\n\nInteger type. Converts the environment variable to a number as well as `NumberValue`, but checks if the environment variable can be converted to `integer`.\n\n### `BooleanValue`\n\nTypescript [boolean type](https://www.typescriptlang.org/docs/handbook/basic-types.html#boolean). Converts the environment variable to a `boolean` from string `'true'` or `'false'`.\n\n### `EnvValue`\n\nIs a generic abstract class that must be extended in this way:\n\n```typescript\ninterface MyType {\n  title: string;\n  tome: number;\n  isRead: boolean;\n}\n\nclass MyType extends EnvValue\u003cMyType\u003e {\n  protected mapper(rawValue: string): MyType {\n    return JSON.parse(rawValue);\n  }\n}\n```\n\nSo the raw env value could be `'{\"title\": \"Harry Potter\", \"tome\": 1, \"isRead\": false}'`. And the Environment converter can use JSON parser to do all the work.\n\n## Examples\n\nLet's imagine we have the environment variable `port` with value `8080`. We could access that in this way:\n\n```typescript\nconst port = Number(Deno.env.get('port'));\n```\n\nBut what if this environment variable is missing? We should check It first:\n\n```typescript\nconst portString = Deno.env.get('port');\nconst portNumber = Number(portString);\n\nif (portNumber === undefined) {\n  throw new Error('port number is missing');\n}\n\nif (Number.isNaN(portNumber)) {\n  throw new Error('Incorrect port variable');\n}\n```\n\nThis routine could be easily done with this:\n\n```typescript\nconst portNumber = new IntValue('port').get();\n```\n\n## Please, note\n\n\u003e If a particular variable is not convertible, `.get()` method throws the exception.\n\n## Importing the module\n\n\u003e `mod.ts` is an entrypoint, other files should not be used.\n\n## Tests\n\n`deno test --allow-env`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokatomnik%2Fdeno-environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokatomnik%2Fdeno-environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokatomnik%2Fdeno-environment/lists"}