Schema Validation
Defining a Schema for Validation
import { schema, loadEnv, InferOut } from "vkrun";
const envSchema = schema().object({
API_KEY: schema().string(),
DEBUG: schema().boolean(),
PORT: schema().number().integer(),
});
type EnvsType = InferOut<typeof envSchema>;
const envs = loadEnv<EnvsType>({ schema: envSchema });
console.log(envs.PORT); // 3000If validation fails,
loadEnv()throws an error, preventing misconfigurations.