nodejs service BETTERPORTAL v1.0.19

service-tunnels-client

betterportal/service-tunnels-client

Client websocket/API service

service websocket tunnel

BetterTunnels

HTTP/HTTPS development tunnels using BSB, H3, AnyVali, websocket clients, Prisma, and PostgreSQL 18.

Dev Setup

npm install
copy .env.example .env
npm run prisma:generate
npm run build

Start PostgreSQL 18 with the included compose file when Docker is available:

docker compose up -d postgres
npm run prisma:migrate

Run the server:

npm run dev

Server startup goes through BSB. Do not start a standalone src/server.ts.

Run a tunnel:

npm run cli -- http 3300

Build the release CLI:

cd cli
go build -o ..\dist\btunnel.exe .

Notes

  • Default domain: tunnels.betterportal.dev.
  • Anonymous configured prefixes are ignored.
  • Authenticated prefix handling is designed but auth is not in the first runtime slice.
  • The H3/WS runtime is owned by the service-tunnels-proxy BSB plugin.
  • The release CLI lives in cli/ and builds to single-file Go binaries for Windows, Linux, and macOS.

Docker

Build the BSB runtime image with this plugin preloaded:

docker build -t better-tunnels:dev .

Run it with a production DATABASE_URL:

docker run --rm -p 8080:8080 -p 8081:8081 -e DATABASE_URL="postgresql://..." better-tunnels:dev

Swarm Deploy

On the server, build local images, run migrations, then deploy the stack:

docker swarm init
docker build -t bettertunnels-app:latest .
docker build -t bettertunnels-migrate:latest --target build .
docker build -t bettertunnels-caddy:latest -f Dockerfile.caddy .
docker stack deploy -c docker-stack.yml bettertunnels

app runs two replicas with start-first rolling updates. Caddy and Postgres are singletons on this one-node swarm. The stack reuses the original Compose volumes by external name.

Installation

Use as a dependency (client reference)
bsb client install betterportal/service-tunnels-client
Deploy as a service
bsb plugin install betterportal/service-tunnels-client
Node.js (npm)
npm install @betterportal/tunnels

Configuration

Configuration options for this plugin:

No configuration required

Events

Events available to clients of this plugin:

Emit and Return

Call these events and receive a response.

proxy.request returnable

Proxy an HTTP request through a connected tunnel client

Fire and Forget

Emit these events with no response expected.

ws.toOrigin fire-and-forget

Relay a public websocket frame to the connected tunnel client

proxy.metrics fire-and-forget

Send final proxy request timings to the connected tunnel client

Available Versions

v1.0.19 v1.0.18 v1.0.17 v1.0.16 v1.0.15 v1.0.14 v1.0.13 v1.0.12 v1.0.11 v1.0.10 v1.0.9 v1.0.8 v1.0.7 v1.0.6 v1.0.5

Metadata