{"id":45952931,"url":"https://github.com/srmlcn/env-ready","last_synced_at":"2026-02-28T13:12:55.810Z","repository":{"id":302678051,"uuid":"1013266066","full_name":"srmlcn/env-ready","owner":"srmlcn","description":"A schema-driven environment variable loader for Node.js projects","archived":false,"fork":false,"pushed_at":"2025-07-04T18:35:59.000Z","size":161,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-09T23:56:32.480Z","etag":null,"topics":["adapter","config","dotenv","env","environment","fail-fast","joi","loader","nodejs","runtime","safe","schema","typescript","validation","variables","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/srmlcn.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,"zenodo":null}},"created_at":"2025-07-03T16:03:33.000Z","updated_at":"2025-07-04T18:35:16.000Z","dependencies_parsed_at":"2025-07-03T17:50:37.344Z","dependency_job_id":null,"html_url":"https://github.com/srmlcn/env-ready","commit_stats":null,"previous_names":["srmlcn/env-ready"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/srmlcn/env-ready","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srmlcn%2Fenv-ready","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srmlcn%2Fenv-ready/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srmlcn%2Fenv-ready/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srmlcn%2Fenv-ready/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srmlcn","download_url":"https://codeload.github.com/srmlcn/env-ready/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srmlcn%2Fenv-ready/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29935106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:00:17.143Z","status":"ssl_error","status_checked_at":"2026-02-28T12:59:13.669Z","response_time":90,"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":["adapter","config","dotenv","env","environment","fail-fast","joi","loader","nodejs","runtime","safe","schema","typescript","validation","variables","zod"],"created_at":"2026-02-28T13:12:53.490Z","updated_at":"2026-02-28T13:12:55.800Z","avatar_url":"https://github.com/srmlcn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# env-ready\n\n[![Test Status](https://img.shields.io/github/actions/workflow/status/srmlcn/env-ready/test.yml?label=tests)](https://github.com/srmlcn/env-ready/actions/workflows/test.yml) [![Test Coverage](https://img.shields.io/codecov/c/github/srmlcn/env-ready)](https://codecov.io/github/srmlcn/env-ready) [![npm](https://img.shields.io/npm/v/env-ready?color=blue)](https://www.npmjs.com/package/env-ready) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\n**env-ready** provides a centralized, fail-fast mechanism for validating environment variables at startup—designed to reduce misconfiguration, improve safety, and support your preferred schema validation library through validator inference.\n\n## Why env-ready?\n\n- **Type-safe by design**: Built with TypeScript for first-class static validation\n- **Fail-fast startup**: Surface configuration errors early, not during execution\n- **Schema-agnostic architecture**: Bring your own validator (`zod`, `joi`, etc.)\n- **Minimal runtime footprint**: Focused, purpose-built utility with no bloat\n\n## Goals\n\n- **Centralize** environment variable validation and access\n- **Fail fast** on missing or malformed variables\n- Enable **schema flexibility** through validator inference\n- Keep the runtime overhead **minimal** and the API **ergonomic**\n\n## Installation\n\n```bash\nnpm install env-ready\n```\n\n## Usage\n\n### Basic Example\n\nCreate a schema using your preferred validation library, for instance, in `src/env.ts`:\n\n```typescript\nimport { loadEnv } from \"env-ready\"\nimport { z } from \"zod\"\n\n// Define your schema using Zod\nconst schema = z.object({\n  FOO: z.string().min(1, \"FOO is required\"),\n  BAR: z.number().optional(),\n})\n\n// Load and validate environment variables\nexport const env = loadEnv(schema)\n```\n\nThen, in your application code:\n\n```typescript\nimport { env } from \"./env\"\n\nconsole.log(env.FOO) // Access validated environment variable\nconsole.log(env.BAR) // Optional variable, may be undefined\n```\n\n### Joi Schemas\n\nJoi schemas are fully supported, but type inference is not available by default. To coerce Joi schemas into TypeScript types, you can use the `joi-to-typescript` package or manually define types that match your Joi schema.\n\n#### JavaScript Example\n\n```javascript\nconst { loadEnv } = require(\"env-ready\")\nconst Joi = require(\"joi\")\n\n// Define your Joi schema\nconst schema = Joi.object({\n  FOO: Joi.string().required(),\n  BAR: Joi.number(), // Optional by default\n})\n\n// Load and validate environment variables\nconst env = loadEnv(schema) // `env` will be typed as `any`\nconsole.log(env.FOO) // Access validated environment variable\nconsole.log(env.BAR) // Optional variable, may be undefined\n```\n\n#### TypeScript Example\n\n```typescript\nimport { loadEnv } from \"env-ready\"\nimport Joi from \"joi\"\n\n// Define your Joi schema\nconst schema = Joi.object({\n  FOO: Joi.string().required(),\n  BAR: Joi.number(), // Optional by default\n})\n\n// Define TypeScript types based on your Joi schema\ntype EnvConfig = {\n  FOO: string\n  BAR?: number // Optional variable\n}\n\n// Load and validate environment variables\nconst env = loadEnv\u003cEnvConfig\u003e(schema) // `env` will be typed as `EnvConfig`\nconsole.log(env.FOO) // Access validated environment variable\nconsole.log(env.BAR) // Optional variable, may be undefined\n```\n\n### Custom Schemas\n\nYou can also create custom schemas that implement the `parse` method:\n\n```typescript\nimport { loadEnv } from \"env-ready\"\n\n// Define a custom schema class\nclass CustomSchema\u003cT\u003e {\n  parse(env: unknown): T {\n    // Custom parsing logic here\n    return env as T\n  }\n}\n\n// Define your custom schema type\ntype MyConfig = { FOO: string; BAR?: number }\n\n// Create an instance of your custom schema\nexport const mySchema = new CustomSchema\u003cMyConfig\u003e()\n\n// Load and validate environment variables using your custom schema\nexport const env = loadEnv(mySchema)\n```\n\n## Validator Compatibility\n\n- [Zod](https://github.com/colinhacks/zod)\n- [Joi](https://github.com/hapijs/joi)\n- Custom schemas\n  - Must implement: `parse\u003cT\u003e(env: unknown): T`\n\n## Contribute\n\nIf you find this project useful, consider:\n\n- **Starring** the repository to improve visibility\n- **Using it** in your projects and **sharing feedback**\n- **Opening issues** for bugs, ideas, or validator support requests\n\nEarly adoption helps refine the direction and expand validator support. Thanks for your support!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrmlcn%2Fenv-ready","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrmlcn%2Fenv-ready","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrmlcn%2Fenv-ready/lists"}