From 14de17ed58c34c0ceb8d261e38bfef902fa8fd39 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Mon, 22 Jul 2024 10:28:15 +0200 Subject: [PATCH] add railway preset --- .changeset/short-shirts-sleep.md | 5 ++++ docs/src/app/docs/customization/page.mdx | 5 ++-- packages/core/src/presets.ts | 34 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .changeset/short-shirts-sleep.md diff --git a/.changeset/short-shirts-sleep.md b/.changeset/short-shirts-sleep.md new file mode 100644 index 0000000..b441f22 --- /dev/null +++ b/.changeset/short-shirts-sleep.md @@ -0,0 +1,5 @@ +--- +"@t3-oss/env-core": minor +--- + +railway preset diff --git a/docs/src/app/docs/customization/page.mdx b/docs/src/app/docs/customization/page.mdx index b89de58..af3831f 100644 --- a/docs/src/app/docs/customization/page.mdx +++ b/docs/src/app/docs/customization/page.mdx @@ -99,11 +99,10 @@ T3 Env ships the following presets out of the box, all importable from the `/pre - `vercel` - Vercel environment variables. See full list [here](https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables). - `uploadthing` - All environment variables required to use [UploadThing](https://uploadthing.com/). More info [here](https://docs.uploadthing.com/getting-started/appdir#add-env-variables). - `render` - Render environment variables. See full list [here](https://docs.render.com/environment-variables#all-runtimes). +- `railway` - Railway provided system environment variables. See full list [here](https://docs.railway.app/reference/variables#railway-provided-variables). - -Feel free to open a PR with more presets! - + Feel free to open a PR with more presets! A preset is just like any other env object, so you can easily create your own: diff --git a/packages/core/src/presets.ts b/packages/core/src/presets.ts index c7c0024..8e5aa37 100644 --- a/packages/core/src/presets.ts +++ b/packages/core/src/presets.ts @@ -66,3 +66,37 @@ export const render = () => }, runtimeEnv: process.env, }); + +/** + * Railway Environment Variables + * @see https://docs.railway.app/reference/variables#railway-provided-variables + */ +export const railway = () => + createEnv({ + server: { + RAILWAY_PUBLIC_DOMAIN: z.string().optional(), + RAILWAY_PRIVATE_DOMAIN: z.string().optional(), + RAILWAY_TCP_PROXY_DOMAIN: z.string().optional(), + RAILWAY_TCP_PROXY_PORT: z.string().optional(), + RAILWAY_TCP_APPLICATION_PORT: z.string().optional(), + RAILWAY_PROJECT_NAME: z.string().optional(), + RAILWAY_PROJECT_ID: z.string().optional(), + RAILWAY_ENVIRONMENT_NAME: z.string().optional(), + RAILWAY_ENVIRONMENT_ID: z.string().optional(), + RAILWAY_SERVICE_NAME: z.string().optional(), + RAILWAY_SERVICE_ID: z.string().optional(), + RAILWAY_REPLICA_ID: z.string().optional(), + RAILWAY_DEPLOYMENT_ID: z.string().optional(), + RAILWAY_SNAPSHOT_ID: z.string().optional(), + RAILWAY_VOLUME_NAME: z.string().optional(), + RAILWAY_VOLUME_MOUNT_PATH: z.string().optional(), + RAILWAY_RUN_UID: z.string().optional(), + RAILWAY_GIT_COMMIT_SHA: z.string().optional(), + RAILWAY_GIT_AUTHOR_EMAIL: z.string().optional(), + RAILWAY_GIT_BRANCH: z.string().optional(), + RAILWAY_GIT_REPO_NAME: z.string().optional(), + RAILWAY_GIT_REPO_OWNER: z.string().optional(), + RAILWAY_GIT_COMMIT_MESSAGE: z.string().optional(), + }, + runtimeEnv: process.env, + });