{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreifojyjolgeuifecikz4l5p5jpli3i2rbtoc3g6pl6q5tmwnktv6gu",
    "uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpg7rxkqv6t2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreicn52dfmvqq5dl7hk3ojymxzg3nxtxfr2dphqjdkrkwf4k4sdhr7i"
    },
    "mimeType": "image/webp",
    "size": 63842
  },
  "path": "/giannielloemmanuelelgtm/i-built-a-zero-dependency-typescript-env-validator-1kd4",
  "publishedAt": "2026-06-29T09:38:47.000Z",
  "site": "https://dev.to",
  "tags": [
    "typescript",
    "node",
    "opensource",
    "webdev",
    "https://github.com/giannielloemmanuele-lgtm/typesafe-env",
    "https://www.npmjs.com/package/@harmand66/typesafe-env",
    "@harmand66"
  ],
  "textContent": "Every Node.js developer has been burned by this at least once:\n\n\n\n    const port = parseInt(process.env.PORT); // NaN if PORT is missing\n    const db = process.env.DATABASE_URL;     // string | undefined — not safe!\n\n\nYour app starts fine locally, then crashes in production because someone forgot to set an env var. The error shows up 3 hours later, not at startup.\n\n##  The solution\n\nI built `@harmand66/typesafe-env` — a tiny, zero-dependency library that validates and types your environment variables at boot time.\n\n\n\n    import { createEnv } from '@harmand66/typesafe-env';\n\n    const env = createEnv({\n      PORT:         { type: 'number',  default: 3000 },\n      DATABASE_URL: { type: 'string',  required: true },\n      DEBUG:        { type: 'boolean', default: false },\n    });\n\n    // ✅ TypeScript knows PORT is a number\n    env.PORT + 1     // 3001 — not \"30001\"\n    env.DATABASE_URL // string — guaranteed, never undefined\n\n\nIf anything is missing or wrong, your app fails immediately at startup with a clear message:\nAll errors at once — no more fixing them one by one.\n\n##  Why not Zod?\n\nZod is great but it's 57kb and requires a lot of boilerplate for this specific use case. `@harmand66/typesafe-env` is zero dependencies and does one thing well.\n\n##  Try it\n\n\n    npm install @harmand66/typesafe-env\n\n\nGitHub: https://github.com/giannielloemmanuele-lgtm/typesafe-env\nnpm: https://www.npmjs.com/package/@harmand66/typesafe-env\n\nWould love any feedback or contributions! 🙏",
  "title": "I built a zero-dependency TypeScript env validator"
}