Skip to content

Instantly share code, notes, and snippets.

@maxgfr
Created April 18, 2023 13:30
Show Gist options
  • Save maxgfr/3a1d6b71cfc9c872527f65b2039640dc to your computer and use it in GitHub Desktop.
Save maxgfr/3a1d6b71cfc9c872527f65b2039640dc to your computer and use it in GitHub Desktop.
Example of env file with zod validation (S/O to Matt Pocok : https://www.youtube.com/watch?v=q1im-hMlKhM)
import { z } from "zod";
const envVariables = z.object({
DATABASE_URL: z.string(),
CUSTOM_STUFF: z.string(),
});
export const ENV = envVariables.parse(process.env);
declare global {
namespace NodeJS {
interface ProcessEnv
extends z.infer<typeof envVariables> {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment