Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preset for Upstash Redis environment variables #312

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-otters-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@t3-oss/env-core": patch
---

add preset for upstash redis environment variables
1 change: 1 addition & 0 deletions docs/src/app/docs/customization/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<Callout type="info">
Feel free to open a PR with more presets!
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/presets-valibot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
RenderEnv,
UploadThingEnv,
UploadThingV6Env,
UpstashRedisEnv,
VercelEnv,
} from "./presets";

Expand Down Expand Up @@ -196,3 +197,16 @@ export const netlify = () =>
} satisfies StandardSchemaDictionary.Matching<NetlifyEnv>,
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<UpstashRedisEnv>,
runtimeEnv: process.env,
});
14 changes: 14 additions & 0 deletions packages/core/src/presets-zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
RenderEnv,
UploadThingEnv,
UploadThingV6Env,
UpstashRedisEnv,
VercelEnv,
} from "./presets";

Expand Down Expand Up @@ -196,3 +197,16 @@ export const netlify = () =>
} satisfies StandardSchemaDictionary.Matching<NetlifyEnv>,
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<UpstashRedisEnv>,
runtimeEnv: process.env,
});
5 changes: 5 additions & 0 deletions packages/core/src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}