π A production-ready API starter with Elysia, Bun, OXC, Drizzle ORM, Neon, and built-in auth, email support, environment validation, and testing.
- π bun for a blazingβfast runtime & package manager.
- β‘οΈ Elysia for an ultraβlight, typeβsafe HTTP framework.
- π·οΈ TypeScript for endβtoβend type safety.
- π Better Auth for dropβin session management.
- π¬ Resend for sending transactional emails with ease.
- ποΈ Drizzle ORM for typeβsafe SQL queries and schema management.
- π’οΈ Neon for scalable, serverless Postgres with branching and edge support.
- π¦ env-schema for runtime-safe environment variable validation.
- π§ͺ vitest for fast unit testing.
- π©Ί OXC for linting + formatting in one tool.
- π©Ί lefthook for lightningβfast Git hooks.
You can either use this template or use tiged:
bunx tiged jimmy-guzman/ts-rest-api-starter my-api
cd my-apiFirst install bun:
curl -fsSL https://bun.sh/install | bashOr if you already have bun installed, upgrade to the latest stable version:
bun upgrade --stablebun installInstall the Neon CLI:
bun add -g neonctlOr with homebrew:
brew install neonctlLogin to your Neon account:
neonctl authCreate a new project:
neonctl projects create --name "my-elysia-api"Get your connection string:
neonctl connection-string --project-id YOUR_PROJECT_IDCopy the example environment file:
cp .env.example .envThe .env.example file contains:
# Database
DATABASE_URL=postgresql://username:password@host/database?sslmode=require
# Auth
BETTER_AUTH_SECRET=your-secret-key-here
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
# Email
RESEND_API_KEY=your-resend-api-key
RESEND_FROM_EMAIL=noreply@yourdomain.comDATABASE_URL: Your Neon database connection string
- Format:
postgresql://username:password@host/database?sslmode=require - Get this from your Neon project dashboard
BETTER_AUTH_SECRET: A secure random string for session encryption
openssl rand -base64 33GitHub OAuth:
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRET- Create a GitHub OAuth app at GitHub Developer Settings
- Set callback URL to:
http://localhost:3000/api/auth/callback/github
Resend Email:
RESEND_API_KEY: Get from Resend DashboardRESEND_FROM_EMAIL: Verified sending domain email
Run database migrations:
bun run db:migrateSeed the database (optional):
bun run db:seedbun run devYour application will be available at:
- API Documentation: http://localhost:3000/docs
- Health Check: http://localhost:3000/health
| Script | Description |
|---|---|
bun run dev |
Start development server with hot reload |
bun run test |
Run all tests |
bun run test:coverage |
Run tests with coverage report |
bun run test:ui |
Run tests with UI interface |
bun run db:generate |
Generate Drizzle schema |
bun run db:migrate |
Run database migrations |
bun run db:push |
Push schema changes to database |
bun run db:studio |
Open Drizzle Studio |
bun run lint |
Lint code with OXC |
bun run lint:fix |
Lint and fix code with OXC |
bun run fmt |
Format code with OXC |
bun run fmt:fix |
Format and fix code with OXC |
bun run typecheck |
Check TypeScript types |
βββ src/
β βββ config/ #
β βββ db/ # Database schemas and connection
β βββ lib/ # Shared utilities (auth, email, env)
β βββ routes/ # API endpoints with tests
β βββ plugins/ # Elysia plugins
β βββ index.ts # Application entry point
βββ docs/ # Project documentation
βββ drizzle.config.ts # Database configuration
βββ .oxcfmtrc.json # Format config
βββ .oxclintrc.json # Linting config
βββ .lefthook.json # Git hooks
βββ package.json