@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
42 lines (32 loc) • 843 B
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import { dlv } from "./dlv.js";
import * as z from "zod";
export interface Env {
UNKEY_ROOT_KEY?: string | undefined;
UNKEY_DEBUG?: boolean | undefined;
}
export const envSchema: z.ZodType<Env, z.ZodTypeDef, unknown> = z.object({
UNKEY_ROOT_KEY: z.string().optional(),
UNKEY_DEBUG: z.coerce.boolean().optional(),
});
let envMemo: Env | undefined = undefined;
/**
* Reads and validates environment variables.
*/
export function env(): Env {
if (envMemo) {
return envMemo;
}
envMemo = envSchema.parse(
dlv(globalThis, "process.env") ?? dlv(globalThis, "Deno.env") ?? {},
);
return envMemo;
}
/**
* Clears the cached env object. Useful for testing with a fresh environment.
*/
export function resetEnv() {
envMemo = undefined;
}