From 8a5c89da5a2ef3ea8212a8854cc406b1c3201a8d Mon Sep 17 00:00:00 2001 From: Abdalrhman Almarakeby Date: Sun, 26 Jan 2025 04:51:04 +0200 Subject: [PATCH] feat: add preset for Upstash Redis environment variables --- .changeset/wild-otters-report.md | 5 +++++ docs/src/app/docs/customization/page.mdx | 1 + packages/core/src/presets-valibot.ts | 14 ++++++++++++++ packages/core/src/presets-zod.ts | 14 ++++++++++++++ packages/core/src/presets.ts | 5 +++++ 5 files changed, 39 insertions(+) create mode 100644 .changeset/wild-otters-report.md diff --git a/.changeset/wild-otters-report.md b/.changeset/wild-otters-report.md new file mode 100644 index 00000000..0b069a9b --- /dev/null +++ b/.changeset/wild-otters-report.md @@ -0,0 +1,5 @@ +--- +"@t3-oss/env-core": patch +--- + +add preset for upstash redis environment variables diff --git a/docs/src/app/docs/customization/page.mdx b/docs/src/app/docs/customization/page.mdx index b3316a8d..d37d53bb 100644 --- a/docs/src/app/docs/customization/page.mdx +++ b/docs/src/app/docs/customization/page.mdx @@ -103,6 +103,7 @@ T3 Env ships the following presets out of the box, all importable from the `/pre - `railway` - Railway provided system environment variables. See full list [here](https://docs.railway.app/reference/variables#railway-provided-variables). - `fly.io` - Fly.io provided machine runtime environment variables. See full list [here](https://fly.io/docs/machines/runtime-environment/#environment-variables). - `netlify` - Netlify provided system environment variables. See full list [here](https://docs.netlify.com/configure-builds/environment-variables). +- `upstashRedis` - Upstash Redis environment variables. More info [here](https://upstash.com/docs/redis/howto/connectwithupstashredis). Feel free to open a PR with more presets! diff --git a/packages/core/src/presets-valibot.ts b/packages/core/src/presets-valibot.ts index cbb40e3c..010d5094 100644 --- a/packages/core/src/presets-valibot.ts +++ b/packages/core/src/presets-valibot.ts @@ -9,6 +9,7 @@ import type { RenderEnv, UploadThingEnv, UploadThingV6Env, + UpstashRedisEnv, VercelEnv, } from "./presets"; @@ -196,3 +197,16 @@ export const netlify = () => } satisfies StandardSchemaDictionary.Matching, runtimeEnv: process.env, }); + +/** + * Upstash redis Environment Variables + * @see https://upstash.com/docs/redis/howto/connectwithupstashredis + */ +export const upstashRedis = () => + createEnv({ + server: { + UPSTASH_REDIS_REST_URL: pipe(string(), url()), + UPSTASH_REDIS_REST_TOKEN: string(), + } satisfies StandardSchemaDictionary.Matching, + runtimeEnv: process.env, + }); diff --git a/packages/core/src/presets-zod.ts b/packages/core/src/presets-zod.ts index 62a6ea83..e8e1f4bf 100644 --- a/packages/core/src/presets-zod.ts +++ b/packages/core/src/presets-zod.ts @@ -9,6 +9,7 @@ import type { RenderEnv, UploadThingEnv, UploadThingV6Env, + UpstashRedisEnv, VercelEnv, } from "./presets"; @@ -196,3 +197,16 @@ export const netlify = () => } satisfies StandardSchemaDictionary.Matching, runtimeEnv: process.env, }); + +/** + * Upstash redis Environment Variables + * @see https://upstash.com/docs/redis/howto/connectwithupstashredis + */ +export const upstashRedis = () => + createEnv({ + server: { + UPSTASH_REDIS_REST_URL: z.string().url(), + UPSTASH_REDIS_REST_TOKEN: z.string(), + } satisfies StandardSchemaDictionary.Matching, + runtimeEnv: process.env, + }); diff --git a/packages/core/src/presets.ts b/packages/core/src/presets.ts index c4473fbc..e35fd10e 100644 --- a/packages/core/src/presets.ts +++ b/packages/core/src/presets.ts @@ -116,3 +116,8 @@ export interface NetlifyEnv { SITE_NAME?: string; SITE_ID?: string; } + +export interface UpstashRedisEnv { + UPSTASH_REDIS_REST_URL: string; + UPSTASH_REDIS_REST_TOKEN: string; +}