TcpProxy
Source:
src/Railway/TcpProxy.ts
A Railway.TcpProxy exposes a service over public TCP. Identity is the
Railway proxy id. There is no in-place update — changing service,
postgres, redis, environment, or applicationPort replaces the
proxy.
Needed so laptop tests and ConnectPostgres from outside the private
network can reach Postgres/Redis.
Postgres
Section titled “Postgres”Attach a proxy to a Postgres service on 5432. domain and
proxyPort are the public endpoint ({domain}:{proxyPort}).
const site = yield* Railway.Project("Site");const db = yield* Railway.Postgres("Db", { project: site });const proxy = yield* Railway.TcpProxy("DbProxy", { postgres: db, environment: site, applicationPort: 5432,});Same shape on 6379.
const site = yield* Railway.Project("Site");const cache = yield* Railway.Redis("Cache", { project: site });const proxy = yield* Railway.TcpProxy("CacheProxy", { redis: cache, environment: site, applicationPort: 6379,});Any service
Section titled “Any service”Pass a Railway.Service or a { serviceId } stub.
const site = yield* Railway.Project("Site");const proxy = yield* Railway.TcpProxy("ApiProxy", { service: { serviceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, environment: site, applicationPort: 8080,});Module-scope declarations
Section titled “Module-scope declarations”Resource-valued props accept the resource or an Effect producing it.
import * as Railway from "alchemy/Railway";
export const Site = Railway.Project("Site");export const Db = Railway.Postgres("Db", { project: Site });export const DbProxy = Railway.TcpProxy("DbProxy", { postgres: Db, environment: Site, applicationPort: 5432,});