This is a template repository for a GraphQL-API-enhanced server powered by Elysia.
- π Modern Stack: Built with Bun, Elysia, and TypeScript for fast development and runtime performance
- π§© Powerful GraphQL API:
- Integration with PostGraphile for auto-generated GraphQL APIs from PostgreSQL schema
- GraphQL Yoga for flexible GraphQL server setup and easy access to Envelop plugin ecosystem
- Grafast for efficient GraphQL execution (query planning)
- Relay specification compliance
- Connection filter plugin for advanced filtering
- Simplify inflection for cleaner schema naming
- No N+1 problem
- π Security:
- GraphQL Armor for securing GraphQL endpoints with operation complexity limits, depth limits, and more
- Schema-wide perimeter authentication support via
useGenericAuth - JWT validation with remote JWKS support via jose
- CORS with configurable allowed origins
- Rate limiting with elysia-rate-limit
- TLS/HTTPS support out of the box
- GraphQL schema introspection disabled in production environments
- β‘ Optimal Performance:
- GraphQL parser and validation caching via Envelop plugins
- PostgreSQL connection pooling
- Optimized GraphQL execution with Grafast
- ποΈ Database Management:
- Drizzle ORM for type-safe database operations
- Automated migrations with
drizzle-kit - Database seeding with drizzle-seed and Faker.js
- Drizzle Studio for visual database management
- π§ͺ Testing:
- Unit tests with Bun test runner
- Testcontainers for isolated PostgreSQL integration tests
- MSW (Mock Service Worker) for API mocking
- Coverage reporting
- π οΈ Developer Experience:
- π’ Production Ready:
- Environment-specific configurations
- Optimized build process
- OpenTelemetry integration for observability
- Health check endpoints (
/health,/ready) for container orchestration - Graceful shutdown handling (SIGTERM/SIGINT)
- Security headers, rate limiting, and TLS/HTTPS
First, cp .env.local.template .env.local and fill in the values. Then, generate TLS certificates by running bun src/scripts/generateTlsCert.ts.
Run tilt up, or:
Install dependencies:
bun installSet up the database (only required once, to create the database):
bun db:setupRun database migrations:
bun db:migrateRun the dev server:
bun dev| Script | Description |
|---|---|
bun db:setup |
Create the database (first-time setup) |
bun db:generate |
Generate migration files from schema changes |
bun db:migrate |
Run pending migrations |
bun db:migrate:drop |
Drop a migration |
bun db:pull |
Introspect existing database schema |
bun db:push |
Push schema changes directly (dev only) |
bun db:seed |
Seed database with test data |
bun db:studio |
Open Drizzle Studio |
bun test
# or in watch mode
bun test:watch
# or test with coverage reporting
bun test:coverageThe code in this repository is licensed under MIT, Β© Omni LLC. See LICENSE.md for more information.