Files
next.orly.dev/app/web
mleku 14b6960070
Some checks failed
Go / build (push) Has been cancelled
Add admin-only "All Events Log" feature with WebSocket integration.
- Implemented an "All Events Log" section accessible only to admin users.
- Added WebSocket-based data fetching to retrieve all events from the relay.
- Included profile caching and metadata fetching for event authors.
- Updated UI components to display events with expandable raw JSON details.
- Adjusted CSS for avatar sizes and improved layout.
- Refactored logout logic to reset all event states.
2025-09-21 16:31:06 +01:00
..

Orly Web Application

This is a React web application that uses Bun for building and bundling, and is automatically embedded into the Go binary when built.

Prerequisites

  • Bun - JavaScript runtime and toolkit
  • Go 1.16+ (for embedding functionality)

Development

There are two ways to develop the web app:

  1. Standalone (recommended for hot reload)
  • Start the Go relay with the embedded web UI disabled so the React app can run on its own dev server with HMR.
  • Configure the relay via environment variables:
# In another shell at repo root
export ORLY_WEB_DISABLE=true
# Optional: if you want same-origin URLs, you can set a proxy target and access the relay on the same port
# export ORLY_WEB_DEV_PROXY_URL=http://localhost:5173

# Start the relay as usual
go run .
  • Then start the React dev server:
cd app/web
bun install
bun dev

When ORLY_WEB_DISABLE=true is set, the Go server still serves the API and websocket endpoints and sends permissive CORS headers, so the dev server can access them cross-origin. If ORLY_WEB_DEV_PROXY_URL is set, the Go server will reverse-proxy non-/api paths to the dev server so you can use the same origin.

  1. Embedded (no hot reload)
  • Build the web app and run the Go server with defaults:
cd app/web
bun install
bun run build
cd ../../
go run .

Building

The React application needs to be built before compiling the Go binary to ensure that the embedded files are available:

# Build the React application
cd app/web
bun install
bun run build

# Build the Go binary from project root
cd ../../
go build

How it works

  1. The React application is built to the app/web/dist directory
  2. The Go embed directive in app/web.go embeds these files into the binary
  3. When the server runs, it serves the embedded React app at the root path

Build Automation

You can create a shell script to automate the build process:

#!/bin/bash
# build.sh
echo "Building React app..."
cd app/web
bun install
bun run build

echo "Building Go binary..."
cd ../../
go build

echo "Build complete!"

Make it executable with chmod +x build.sh and run with ./build.sh.