rjoydip/try-elysia

[EXPERIMENT] - A high-performance full-stack server application built with ElysiaJS and TanStack Start, designed to run on multiple JavaScript runtimes.

★ 0Forks 0TypeScriptGitHub ↗Compare

README

Try Elysia

React Doctor CI Release

A high-performance full-stack server application built with ElysiaJS and TanStack Start, designed to run on multiple JavaScript runtimes.

Warning

⚠️ Experimental Repository This repo is for prototyping and experimentation only — it may be unstable and is not for production use.

👉 Use the official project instead: https://github.com/rjoydip/tss-elysia


If you find something useful here, feel free to explore—but for any serious usage, always prefer the recommended repository above.

Features

  • Multi-Runtime Support - Deploy to Bun, Node.js, or Cloudflare Workers
  • Type-Safe API - End-to-end type safety with ElysiaJS and OpenAPI
  • Authentication - Secure auth with better-auth and session management
  • Database - Type-safe database access with Drizzle ORM
  • Real-time - WebSocket and Server-Sent Events (SSE) support
  • Security - Helmet middleware, rate limiting, CORS
  • Observability - OpenTelemetry integration for tracing
  • Automated Releases - Changesets for semantic versioning and changelogs

Tech Stack

Category Technology
Backend ElysiaJS
Frontend React Start (TanStack Router)
Runtimes Bun, Node.js, Cloudflare Workers
Database Drizzle ORM + SQLite (libSQL)
Auth better-auth
Styling TailwindCSS v4
Docs OpenAPI/Swagger
Releases Changesets + GitHub Actions

Prerequisites

  • Bun v1.0 or later
  • Node.js v18 or later (optional, for Node runtime)
# Install Bun
curl -fsSL https://bun.sh/install | bash

Quick Start

# Install dependencies
bun install

# Start full-stack development
bun run dev

# Open in browser
open http://localhost:3000/

Scripts Overview

Development

bun run dev              # Quick start (server + client)
bun run server:dev       # Bun server with hot reload
bun run server:dev:node  # Node.js server with hot reload
bun run server:dev:workerd # Cloudflare Workers dev
bun run server:dev:edge  # Edge runtime dev
bun run client:dev       # Frontend only (Vite)

Build

bun run build           # Build all targets
bun run build:bun       # Standalone Bun binary
bun run build:node      # Node.js executable
bun run client:build    # Frontend build

Database

bun run db:generate     # Generate Drizzle schema
bun run db:migrate       # Run migrations
bun run db:push          # Push schema to database
bun run db:pull          # Pull schema from database
bun run db:seed          # Seed database with data
bun run db:studio        # Open Drizzle Studio

Code Quality

bun run lint            # Lint with oxlint + format check
bun run lint:fix        # Fix lint issues
bun run fmt             # Format code
bun run typecheck       # TypeScript type checking
bun run react:doctor    # React health check

Testing

bun test               # Run all tests
bun test:watch         # Watch mode
bun test:coverage      # With coverage report

Releases (Changesets)

bun changeset add       # Add a changeset for your changes
bun changeset version   # Bump versions (CI uses this)
bun release            # Publish release

Project Structure

src/
├── _api.ts              # API routes definition
├── _app.ts              # Main application + middleware
├── _config.ts           # Configuration and logger
├── _env.ts              # Environment variables
├── auth.ts              # better-auth configuration
├── router.tsx           # TanStack Router setup
├── routes/              # Frontend routes
│   ├── __root.tsx      # Root layout
│   └── index.tsx        # Home page
├── middlewares/          # Middleware implementations
│   └── _auth.ts         # Authentication middleware
├── features/             # Feature modules
│   └── user/            # User feature (routes, service)
├── db/                   # Database layer
│   ├── _client.ts       # Database client
│   └── schema/          # Drizzle schema
├── runtime/              # Multi-runtime entries
│   ├── bun.ts           # Bun runtime
│   ├── node.ts          # Node.js runtime
│   ├── workerd.ts       # Cloudflare Workers
│   └── edge.ts          # Edge functions
└── components/           # React components

.changeset/               # Changesets for versioning
.github/workflows/         # GitHub Actions CI/CD

API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/sign-in Sign in
POST /api/auth/sign-up Sign up
POST /api/auth/sign-out Sign out
GET /api/auth/session Get current session

Users (Protected)

Method Endpoint Description
GET /api/user Get all users (paginated)
GET /api/user/:id Get user by ID
POST /api/user Create user
PUT /api/user/:id Update user
DELETE /api/user/:id Delete user

Public

Method Endpoint Description
GET /api/ API welcome
GET /api/health Health check
GET /api/sse Server-Sent Events
WS /api/chat WebSocket chat

API documentation available at /openapi when server is running.

Environment Variables

Required

BETTER_AUTH_SECRET=your-secret-key
BETTER_AUTH_BASE_URL=http://localhost:3000/api
DATABASE_URL=file:sqlite.db

Optional

PORT=3000
DATABASE_AUTH_TOKEN=your-token
TLS_CERT_PATH=/path/to/cert.pem
TLS_KEY_PATH=/path/to/key.pem

See docs/environment-variables.md for full documentation.

Deployment

Cloudflare Workers

bun run deploy

Bun

bun run build:bun
./server

Node.js

bun run build:node
node dist/server.js

Contributing

We use Changesets for versioning and changelogs.

Making Changes

  1. Make your changes in a feature branch

  2. Add a changeset to describe what changed:

    bun changeset add
    • Select the try-elysia package
    • Choose bump type: patch, minor, or major
    • Write a description of your changes
  3. Commit your changes including the changeset file

  4. Open a PR - CI will run tests and linting

Release Process

Releases are automated via GitHub Actions when changes are merged to main:

  1. Changesets detects new changeset files
  2. Updates version in package.json
  3. Generates CHANGELOG.md with PR links
  4. Creates GitHub Release with binaries
  5. Publishes to GitHub Packages (if applicable)

Nightly Builds

Dev builds are automatically created nightly at midnight UTC. They include:

  • Latest code from main
  • Version: 0.0.0-dev.YYYYMMDD.commitCount
  • Download from the "Nightly Dev" GitHub Release

See CONTRIBUTING.md for detailed contribution guidelines.

Generate Auth Schema

For regenerating better-auth schema:

bun x @better-auth/cli@latest generate --output ./src/db/schema/auth.ts

Documentation

License

MIT

Contributors

rjoydip

Issues