Skip to content

Commit

Permalink
feat: add railway preset (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge authored Jul 22, 2024
1 parent 8737daf commit 870608d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
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,
});

0 comments on commit 870608d

Please sign in to comment.