{"id":20291126,"url":"https://github.com/arundo/typed-env","last_synced_at":"2025-07-27T06:34:18.792Z","repository":{"id":209656033,"uuid":"724523542","full_name":"arundo/typed-env","owner":"arundo","description":"Typed and validated environment variables made easy","archived":false,"fork":false,"pushed_at":"2024-04-10T09:15:28.000Z","size":103,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-16T17:05:30.594Z","etag":null,"topics":["environment-variables","types","typescript","validation","zod"],"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/arundo.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}},"created_at":"2023-11-28T08:56:13.000Z","updated_at":"2024-04-10T07:58:12.000Z","dependencies_parsed_at":"2023-12-01T14:13:32.682Z","dependency_job_id":"bd462501-9736-4cbd-8af7-3ddfc3da620b","html_url":"https://github.com/arundo/typed-env","commit_stats":{"total_commits":45,"total_committers":3,"mean_commits":15.0,"dds":"0.37777777777777777","last_synced_commit":"66a244af2bd37f7c3707db019bb882c09f4af343"},"previous_names":["arundo/typed-env"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/arundo/typed-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arundo%2Ftyped-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arundo%2Ftyped-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arundo%2Ftyped-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arundo%2Ftyped-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arundo","download_url":"https://codeload.github.com/arundo/typed-env/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arundo%2Ftyped-env/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267317361,"owners_count":24068427,"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":["environment-variables","types","typescript","validation","zod"],"created_at":"2024-11-14T15:10:34.633Z","updated_at":"2025-07-27T06:34:18.774Z","avatar_url":"https://github.com/arundo.png","language":"TypeScript","readme":"# @arundo/typed-env\n\nTyped environment variables using [Zod](https://zod.dev/).\n\n## Installation\n\n```sh\nnpm install @arundo/typed-env\n\n# or\n\nyarn add @arundo/typed-env\n\n# or\n\npnpm add @arundo/typed-env\n```\n\n## Usage\n\nCreate a environment file with a schema and use `typeEnvironment` to create a typed environment object:\n\n```ts\n// environment.ts\nimport { z } from 'zod';\nimport { typeEnvironment } from '@arundo/typed-env';\n\nexport const envSchema = z.object({\n  NODE_ENV: z.enum(['test', 'development', 'production']),\n  PORT: z.coerce.number().int().default(3000),\n});\n\nexport const environment = typeEnvironment(envSchema);\n```\n\nImport the environment object and use it:\n\n```ts\n// server.ts\nimport { environment } from './environment';\n\nconsole.log(environment.NODE_ENV); // 'development' - type string\nconsole.log(environment.PORT); // 3000 - type number\n```\n\nSet naming convention of environment variables:\n\n```ts\n// environment.ts\n\n/* ... as usual ... */\n\nexport const environment = typeEnvironment(envSchema, { transform: 'camelcase' });\n```\n\n```ts\n// server.ts\nimport { environment } from './environment';\n\nconsole.log(environment.nodeEnv); // 'development' - type string\nconsole.log(environment.port); // 3000 - type number\n```\n\nIf you for some reason need to access the raw environment object, you can add types like this:\n\n```ts\n// environment.ts\nimport { z } from 'zod';\nimport { typeEnvironment } from '@arundo/typed-env';\n\nexport const envSchema = z.object({\n  PORT: z.coerce.number().int().default(3000),\n});\n\nexport const environment = typeEnvironment(envSchema, { transform: 'camelcase' });\n\ndeclare global {\n  namespace NodeJS {\n    interface ProcessEnv extends Record\u003ckeyof z.infer\u003ctypeof envSchema\u003e, string | undefined\u003e {}\n  }\n}\n\nconsole.log(process.env.PORT); // '3000' - type string | undefined\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farundo%2Ftyped-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farundo%2Ftyped-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farundo%2Ftyped-env/lists"}