0.0.5 • Published 1 year ago
gen-typed-env v0.0.5
Generate Typed Env
Create a type-safe config from your .env file.
Usage
npx gen-typed-env --file .env!NOTE You can omit the
--fileflag if you have a.envfile in the current directory.
Example
USERNAME=Complexlity
PROFILE_URL=https://github.com/Complexlity/typesafe-env/
COMPANYNAME=npx gen-typed-envWill generate the following file:
import { z } from "zod";
import { config: dotenvConfig } from "dotenv";
dotenvConfig();
export const env = z.object({
USERNAME: z.string(),
PROFILE_URL: z.url(),
COMPANYNAME: z.string().optional(),
});
const config = env.parse(process.env);
export default config;