A RESTful API for Fantasy Premier League data built with Elysia.js and Bun.
- Current event and deadline information
- Fixtures for the next gameweek
- Team information
- Player statistics
- League standings
This application uses two separate Redis instances:
-
Data Redis (Read-Only)
- Used for accessing application data
- Configured with
REDIS_*environment variables - This is a read-only replica and should not be written to
-
Cache Redis (Read/Write)
- Used exclusively for caching
- Configured with
CACHE_REDIS_*environment variables - Requires write access
Make sure both Redis instances are properly configured in your environment.
- Clone the repository
- Copy
.env.exampleto.envand configure your environment - Install dependencies:
bun install - Run the development server:
bun dev
API documentation is available at /swagger when the server is running.
Run tests with: bun test
- Runtime: Bun - A fast JavaScript runtime, bundler, and package manager
- Framework: Elysia.js - A high-performance TypeScript web framework
- Database: MySQL with Drizzle ORM for type-safe database operations
- Testing: Bun's built-in test runner with Jest-compatible API
- Logging: Pino for structured logging with file rotation
- Caching: Redis for high-performance caching
- Documentation: Swagger via @elysiajs/swagger plugin
- Generate migrations:
bun run db:generate - Open Drizzle Studio:
bun run db:studio
The database schema is defined using Drizzle ORM in the src/db/schema directory. Each table has its own file with type-safe column definitions. The schema is automatically validated against the database structure during tests.
Database connection settings are managed in src/config/db.ts and used by the Drizzle ORM instance in src/db/index.ts. The connection is configured to:
- Use connection pooling for better performance
- Automatically reconnect on connection loss
- Support proper cleanup on application shutdown
You can use Drizzle Studio to visually explore your database schema and data by running:
bun run db:studioThis will start a web interface where you can browse tables, run queries, and view relationships.
The API uses Pino for structured logging. Logs are categorized into different files:
app.log: Main application logshttp.log: HTTP request/response logsservice.log: Service layer operation logserror.log: Error logs from all sources
This project is licensed under the MIT License.