Changelog
v0.3.0 - February 4, 2025
Architecture Refactoring
- Lightweight Framework: Refactored ElysiaJS backend framework to a lightweight custom framework, specifically optimized for Cloudflare Workers
- Removed approximately 15 heavyweight dependencies, core framework code < 10KB
- Implemented on-demand loading architecture, only initializing necessary services per request
- Optimized startup time and memory footprint
New Features
-
Caching System: Implemented a flexible caching system supporting both database and S3
- Added
CACHE_STORAGE_MODEenvironment variable, supportingdatabaseors3mode - Supports automatic serialization and deserialization of cache data
- Added cache table for high-frequency data storage
- Added
-
HyperLogLog Statistics: Migrated PV/UV statistics to HyperLogLog algorithm
- Uses 16384 registers with ~0.81% error rate
- Added
visit_statstable with pv counter and hll_data - Optimized feed visit tracking from O(n) query to O(1) lookup
- Significantly reduced query time for high-traffic articles
-
Error Handling System: Implemented comprehensive error handling mechanism
- Added structured error classes (ValidationError, NotFoundError, etc.)
- Implemented
GlobalErrorBoundaryfor capturing React rendering errors - Added
useErrorhooks for handling asynchronous operations and API calls - Server-side middleware for logging errors and generating request IDs
-
Cookie Authentication: Migrated from Authorization Header to Cookie-based authentication
- Backend sets HttpOnly, Secure, SameSite=lax cookies
- Frontend removes Authorization Header, relies on browser cookies
- Enhanced CSRF protection
Improvements and Optimizations
-
API Client Refactoring: Replaced Elysia/Eden with custom API client
- Removed @elysiajs/eden and rin-server dependencies
- Created type-safe API client
- Simplified API call pattern (from treaty pattern to direct method calls)
- BREAKING CHANGE: Client API interface changed, e.g.,
client.feed.index.get()→client.feed.list()
-
Custom OAuth Implementation: Replaced elysia-oauth2 with custom OAuth2 implementation
- Generic OAuth2 plugin architecture supporting any OAuth2 provider
- Built-in GitHub OAuth provider as default
- CSRF protection via state parameter validation
- Full TypeScript type support
-
Dependency Injection Refactoring: Replaced typedi with native mechanisms
- Removed typedi dependency injection container
- Uses Elysia's decorate() and derive() for dependency injection
- Services access dependencies via store instead of Container.get()
-
Friend Links Optimization: Updated Friend interface and adjusted related API calls
- Improved type safety
Bug Fixes
- Fixed UV migration to HLL failure
- Fixed schema validation issue in GitHub callback route
- Fixed query parameter integer parsing
- Fixed CORS preflight request handling
- Optimized code and reduced bundle size
Database Migrations
- Added cache table
cache(key, type, data, created_at, updated_at) - Added visit stats table
visit_stats(feed_id, pv, hll_data) - Database migration script:
0006.sql
Environment Variables
New environment variable:
v0.2.0 Updated on 2024-06-07
- Added
S3_CACHE_FOLDERenvironment variable - Updated the list of encrypted environment variables, keeping only the essential ones
- Encrypted variables can now be configured directly via GitHub
- Updated GitHub variable configuration, added encrypted variables that must be configured through GitHub (S3 storage for SEO index storage)
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETare now prefixed withRIN_(RIN_GITHUB_CLIENT_ID,RIN_GITHUB_CLIENT_SECRET) to solve the issue where GitHub variables cannot start withGITHUB_. Variables configured through the Cloudflare panel (GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRET) are not affected.
Migration Guide
For normal version updates without special instructions, simply synchronize the forked repository.
v0.2.0 Migration Guide
- Due to the introduction of SEO optimization, it is necessary to configure S3 storage environment variables in GitHub. Therefore, you need to additionally configure the following environment variables in GitHub (plain text, add to Variables):
Additionally, add the following encrypted environment variables (encrypted, add to Secrets):
These environment variables were previously configured through the Cloudflare panel. Now they need to be migrated to GitHub. The new version's deployment GitHub Action will automatically upload them to Cloudflare, so you no longer need to configure these environment variables in the Cloudflare panel.