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

feat: add railway preset #253

Merged
merged 1 commit into from
Jul 22, 2024
Merged
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/short-shirts-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@t3-oss/env-core": minor
---

railway preset
5 changes: 2 additions & 3 deletions docs/src/app/docs/customization/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<Callout type="info">

Feel free to open a PR with more presets!

Feel free to open a PR with more presets!
</Callout>

A preset is just like any other env object, so you can easily create your own:
Expand Down
34 changes: 34 additions & 0 deletions packages/core/src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});