Skip to content

Commit 00c35f2

Browse files
Add preset for Upstash Redis environment variables (#312)
1 parent 9d647c0 commit 00c35f2

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

.changeset/wild-otters-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@t3-oss/env-core": patch
3+
---
4+
5+
add preset for upstash redis environment variables

docs/src/app/docs/customization/page.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ T3 Env ships the following presets out of the box, all importable from the `/pre
103103
- `railway` - Railway provided system environment variables. See full list [here](https://docs.railway.app/reference/variables#railway-provided-variables).
104104
- `fly.io` - Fly.io provided machine runtime environment variables. See full list [here](https://fly.io/docs/machines/runtime-environment/#environment-variables).
105105
- `netlify` - Netlify provided system environment variables. See full list [here](https://docs.netlify.com/configure-builds/environment-variables).
106+
- `upstashRedis` - Upstash Redis environment variables. More info [here](https://upstash.com/docs/redis/howto/connectwithupstashredis).
106107

107108
<Callout type="info">
108109
Feel free to open a PR with more presets!

packages/core/src/presets-valibot.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
RenderEnv,
1010
UploadThingEnv,
1111
UploadThingV6Env,
12+
UpstashRedisEnv,
1213
VercelEnv,
1314
} from "./presets";
1415

@@ -196,3 +197,16 @@ export const netlify = () =>
196197
} satisfies StandardSchemaDictionary.Matching<NetlifyEnv>,
197198
runtimeEnv: process.env,
198199
});
200+
201+
/**
202+
* Upstash redis Environment Variables
203+
* @see https://upstash.com/docs/redis/howto/connectwithupstashredis
204+
*/
205+
export const upstashRedis = () =>
206+
createEnv({
207+
server: {
208+
UPSTASH_REDIS_REST_URL: pipe(string(), url()),
209+
UPSTASH_REDIS_REST_TOKEN: string(),
210+
} satisfies StandardSchemaDictionary.Matching<UpstashRedisEnv>,
211+
runtimeEnv: process.env,
212+
});

packages/core/src/presets-zod.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
RenderEnv,
1010
UploadThingEnv,
1111
UploadThingV6Env,
12+
UpstashRedisEnv,
1213
VercelEnv,
1314
} from "./presets";
1415

@@ -196,3 +197,16 @@ export const netlify = () =>
196197
} satisfies StandardSchemaDictionary.Matching<NetlifyEnv>,
197198
runtimeEnv: process.env,
198199
});
200+
201+
/**
202+
* Upstash redis Environment Variables
203+
* @see https://upstash.com/docs/redis/howto/connectwithupstashredis
204+
*/
205+
export const upstashRedis = () =>
206+
createEnv({
207+
server: {
208+
UPSTASH_REDIS_REST_URL: z.string().url(),
209+
UPSTASH_REDIS_REST_TOKEN: z.string(),
210+
} satisfies StandardSchemaDictionary.Matching<UpstashRedisEnv>,
211+
runtimeEnv: process.env,
212+
});

packages/core/src/presets.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,8 @@ export interface NetlifyEnv {
116116
SITE_NAME?: string;
117117
SITE_ID?: string;
118118
}
119+
120+
export interface UpstashRedisEnv {
121+
UPSTASH_REDIS_REST_URL: string;
122+
UPSTASH_REDIS_REST_TOKEN: string;
123+
}

0 commit comments

Comments
 (0)