{"_id":"@aman179102/typeenv","_rev":"2-2411b85c0f9c9b503e9666299e1a25a0","name":"@aman179102/typeenv","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@aman179102/typeenv","version":"0.1.0","keywords":["env","environment","validation","type-safe","typescript","dotenv","env-variables","schema","json-schema","config","environment-variables","env-validation","type-env"],"author":"","license":"MIT","_id":"@aman179102/typeenv@0.1.0","maintainers":[{"name":"aman179102","email":"amankk179102@gmail.com"}],"homepage":"https://github.com/aman179102/type-env#readme","bugs":{"url":"https://github.com/aman179102/type-env/issues"},"dist":{"shasum":"29ad32ebcf3458762954b6c07358527254185eca","tarball":"https://registry.npmjs.org/@aman179102/typeenv/-/typeenv-0.1.0.tgz","fileCount":25,"integrity":"sha512-J3Tth68RwJv/apw1+mnxevdZDiwIMTImJr6VXZwpjBr2i0SFWfnmTUw9+lW8os9avH97mNmid0mcK4CYP6DBAg==","signatures":[{"sig":"MEQCIHrq/+zf+MJHCwOjYW25AklkL1CQsoGnOvQCdp/80Q0kAiAsMn2B5VbXEYXnwxel1H6DYLaZROOCJB+pjBU4OgiBvQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32519},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"626cb96fb193bda72e2aa5de7f10c2e7e24d18a7","scripts":{"test":"node --experimental-vm-modules --test src/**/*.test.ts","build":"tsc","typecheck":"tsc --noEmit","prepublish":"npm run build"},"_npmUser":{"name":"aman179102","email":"amankk179102@gmail.com"},"repository":{"url":"git+https://github.com/aman179102/type-env.git","type":"git"},"_npmVersion":"10.8.2","description":"Zero-dependency type-safe environment variable validator with auto-generated .env.example and TypeScript types","directories":{},"_nodeVersion":"20.20.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/typeenv_0.1.0_1783320019547_0.221265358008917","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aman179102/typeenv","version":"0.1.1","description":"Zero-dependency type-safe environment variable validator with auto-generated .env.example and TypeScript types","keywords":["env","environment","validation","type-safe","typescript","dotenv","env-variables","schema","json-schema","config","environment-variables","env-validation","type-env"],"license":"MIT","author":"","repository":{"type":"git","url":"git+https://github.com/aman179102/type-env.git"},"bugs":{"url":"https://github.com/aman179102/type-env/issues"},"homepage":"https://github.com/aman179102/type-env#readme","type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"tsc","test":"node --experimental-vm-modules --test src/**/*.test.ts","typecheck":"tsc --noEmit","prepublish":"npm run build"},"engines":{"node":">=18.0.0"},"_id":"@aman179102/typeenv@0.1.1","gitHead":"7f7b2aad295aca387639cf2981960cedfa63eb5b","_nodeVersion":"20.20.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-7z0mEyc2xznyuS9/dmONgKQ1Fisv3v6bGazCA7ECuJ6lbLWxo0lMUrmaqprqXIYMatBwULwSpxrzvbZf/o9gkg==","shasum":"aab3e0ff01a7a19633ab1e2c6f2c3d04bb094841","tarball":"https://registry.npmjs.org/@aman179102/typeenv/-/typeenv-0.1.1.tgz","fileCount":26,"unpackedSize":37610,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCiBHrFWk0oFz6DJkd6lS/48lk3buJ67hYGhfW55aLWpQIhALKDl0WfkYyNIJpLns7Kem/fn7yNVkk2/tQ8qauk1Vh3"}]},"_npmUser":{"name":"aman179102","email":"amankk179102@gmail.com"},"directories":{},"maintainers":[{"name":"aman179102","email":"amankk179102@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typeenv_0.1.1_1783401654602_0.6350401682067841"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T06:40:19.329Z","modified":"2026-07-07T05:20:54.826Z","0.1.0":"2026-07-06T06:40:19.696Z","0.1.1":"2026-07-07T05:20:54.734Z"},"bugs":{"url":"https://github.com/aman179102/type-env/issues"},"license":"MIT","homepage":"https://github.com/aman179102/type-env#readme","keywords":["env","environment","validation","type-safe","typescript","dotenv","env-variables","schema","json-schema","config","environment-variables","env-validation","type-env"],"repository":{"type":"git","url":"git+https://github.com/aman179102/type-env.git"},"description":"Zero-dependency type-safe environment variable validator with auto-generated .env.example and TypeScript types","maintainers":[{"name":"aman179102","email":"amankk179102@gmail.com"}],"readme":"<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/aman179102/type-env/main/assets/logo.svg\" width=\"120\" alt=\"typeenv logo\" />\n</p>\n\n<h1 align=\"center\">@aman179102/typeenv</h1>\n\n<p align=\"center\">\n  <strong>Zero-dependency type-safe environment variable validator</strong>\n  <br />\n  JSON Schema → typed env vars · auto `.env.example` · CI validation\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/@aman179102/typeenv\">\n    <img src=\"https://img.shields.io/npm/v/@aman179102/typeenv?color=blue&label=npm\" alt=\"npm version\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/@aman179102/typeenv\">\n    <img src=\"https://img.shields.io/npm/dm/@aman179102/typeenv?color=blue\" alt=\"npm downloads\" />\n  </a>\n  <a href=\"https://bundlephobia.com/package/@aman179102/typeenv\">\n    <img src=\"https://img.shields.io/bundlephobia/minzip/@aman179102/typeenv?color=green\" alt=\"bundle size\" />\n  </a>\n  <a href=\"LICENSE\">\n    <img src=\"https://img.shields.io/npm/l/@aman179102/typeenv?color=blue\" alt=\"license\" />\n  </a>\n  <a href=\"https://github.com/aman179102/type-env\">\n    <img src=\"https://img.shields.io/github/stars/aman179102/type-env?style=social\" alt=\"stars\" />\n  </a>\n</p>\n\n---\n\n## Install\n\n```bash\nnpm i @aman179102/typeenv\n```\n\nZero external dependencies. Works with Node.js 18+, Bun, and Deno.\n\n## Quick Start\n\n### 1. Define your schema\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"DATABASE_URL\": {\n      \"type\": \"string\",\n      \"description\": \"Database connection string\",\n      \"required\": true\n    },\n    \"PORT\": {\n      \"type\": \"number\",\n      \"default\": 3000,\n      \"minimum\": 1024,\n      \"maximum\": 65535\n    },\n    \"NODE_ENV\": {\n      \"type\": \"string\",\n      \"enum\": [\"development\", \"production\", \"test\"],\n      \"default\": \"development\"\n    },\n    \"API_KEY\": {\n      \"type\": \"string\",\n      \"required\": true,\n      \"sensitive\": true\n    }\n  },\n  \"required\": [\"DATABASE_URL\", \"API_KEY\"]\n}\n```\n\n### 2. Use in code\n\n```ts\nimport { createEnv } from '@aman179102/typeenv';\n\nconst env = createEnv({ schema: './env.schema.json' });\n\n// Fully typed with autocomplete\nconsole.log(env.DATABASE_URL); // string\nconsole.log(env.PORT);         // number (auto-coerced from string)\nconsole.log(env.NODE_ENV);     // 'development' | 'production' | 'test'\nconsole.log(env.API_KEY);      // string (masked in error logs)\n```\n\n## CLI (optional)\n\n```bash\nnpx @aman179102/typeenv-cli init        # Create env.schema.json\nnpx @aman179102/typeenv-cli generate    # .env.example + env.d.ts\nnpx @aman179102/typeenv-cli check       # Validate .env against schema\n```\n\n## Why typeenv?\n\n| Feature | typeenv | dotenv | envalid | @t3-oss/env |\n|---------|---------|--------|---------|-------------|\n| Zero dependencies | **✅** | ✅ | ✅ | ❌ (needs Zod) |\n| TypeScript types | **✅** | ❌ | ❌ | ✅ |\n| Auto `.env.example` | **✅** | ❌ | ❌ | ❌ |\n| Auto `env.d.ts` | **✅** | ❌ | ❌ | ❌ |\n| JSON Schema → types | **✅** | ❌ | ❌ | ❌ |\n| CI validation | **✅** | ❌ | ❌ | ❌ |\n| Secret masking | **✅** | ❌ | ❌ | ❌ |\n| Framework agnostic | **✅** | ✅ | ✅ | ❌ (Next.js) |\n\n## API Reference\n\n### `createEnv(config)`\n\n```ts\nconst env = createEnv({\n  schema: './env.schema.json',  // Path or inline object\n  strict: true,                  // Throw on missing required (default: true)\n  prefix: 'MY_APP_',            // Filter by prefix (optional)\n});\n```\n\n### `validateEnv(env, schema)`\n\n```ts\nimport { validateEnv } from '@aman179102/typeenv';\n\nconst result = validateEnv(process.env, schema);\nresult.valid;    // boolean\nresult.errors;   // ValidationError[]\n```\n\n### `generateEnvExample(schema)`\n\n```ts\nimport { generateEnvExample } from '@aman179102/typeenv';\n\nconst content = generateEnvExample(schema);\n// → string for .env.example\n```\n\n### `generateTypeDefinitions(schema)`\n\n```ts\nimport { generateTypeDefinitions } from '@aman179102/typeenv';\n\nconst types = generateTypeDefinitions(schema);\n// → string for env.d.ts\n```\n\n## Schema Fields\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `type` | `string \\| number \\| boolean \\| integer` | Value type |\n| `required` | `boolean` | Variable is mandatory |\n| `default` | `string \\| number \\| boolean` | Default if not set |\n| `description` | `string` | Human-readable help text |\n| `pattern` | `string` (regex) | Regex validation |\n| `enum` | `array` | Allowed values |\n| `minimum` / `maximum` | `number` | Range (number/integer) |\n| `minLength` / `maxLength` | `number` | String length limits |\n| `sensitive` | `boolean` | Mask in error messages |\n\n## Examples\n\n### Express.js\n\n```ts\nimport { createEnv } from '@aman179102/typeenv';\n\nconst env = createEnv({ schema: './env.schema.json' });\n\napp.listen(env.PORT, () => {\n  console.log(`Server on port ${env.PORT}`);\n});\n```\n\n### Inline schema\n\n```ts\nconst env = createEnv({\n  schema: {\n    type: 'object',\n    properties: {\n      PORT: { type: 'number', default: 3000 },\n      NODE_ENV: { type: 'string', enum: ['dev', 'prod'], default: 'dev' },\n    },\n    required: [],\n  },\n});\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}