Skip to content

Instantly share code, notes, and snippets.

@maxktz
Last active March 20, 2025 01:59
Show Gist options
  • Save maxktz/7845a347f0c427c8c4337a83bc9eb305 to your computer and use it in GitHub Desktop.
Save maxktz/7845a347f0c427c8c4337a83bc9eb305 to your computer and use it in GitHub Desktop.
Env `pnpm install dotenv zod`
import dotenv from "dotenv";
import { z } from "zod";
dotenv.config();
const envSchema = z.object({
RABBITMQ_URL: z.string().url(),
RABBITMQ_QUEUE: z.string().min(1),
});
const parse = envSchema.safeParse(process.env);
if (!parse.success) {
console.error("❌ Invalid ENV variables:", parse.error.format());
process.exit(1);
}
export const env = parse.data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment