Skip to content

Commit

Permalink
feat: add preset for Upstash Redis environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdalrhman-Almarakeby committed Jan 26, 2025
1 parent c2aad55 commit 2005ffd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
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 @@ -10,6 +10,7 @@ import type {
UploadThingEnv,
UploadThingV6Env,
VercelEnv,
UpstashRedisEnv,
} 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 @@ -10,6 +10,7 @@ import type {
UploadThingEnv,
UploadThingV6Env,
VercelEnv,
UpstashRedisEnv,
} 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;
}

0 comments on commit 2005ffd

Please sign in to comment.