fletch 2.0.4
fletch: ^2.0.4 copied to clipboard
A fast, Express-inspired HTTP framework for Dart. Build production-ready REST APIs with built-in sessions, CORS, rate limiting, and middleware support.
Changelog #
All notable changes to fletch will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
2.0.4 - 2026-01-01 #
Added #
- Unified Controller Support
- Moved
useControllertoBaseContainer, enabling controllers in bothFletchapps andIsolatedContainermodules. - Added documentation example for
BaseContainer.useController.
- Moved
Changed #
- Refactoring
Controller.initializenow acceptsBaseContainerinstead ofFletch, allowing for more flexible controller reuse.- Removed duplicate
useControllerimplementation fromFletchclass (now inherited).
Documentation #
- Significant overhaul of documentation site:
- Added new "Configuration" guide.
- Added "Requests & Responses" API reference.
- Updated "Routing" and "Error Handling" guides.
- Implemented SEO basics (sitemap, meta tags).
2.0.3 - 2025-12-30 #
Added #
- Simplified Mounting API
- Added
Fletch.mount(String prefix, IsolatedContainer container)convenience method. - Allows easy mounting of isolated containers with automatic prefix handling:
app.mount('/auth', authModule).
- Added
- IsolatedContainer Extensions
- Added
withPrefix(String newPrefix)method to support easy re-mounting and configuration of containers.
- Added
- Flexible Response Encoding
- Added an optional
Encoding encodingparameter toResponsehelper methods (json,text,html,xml). - Defaults to
utf8but allows overriding for specific needs (e.g., legacy systems).
- Added an optional
Fixed #
- Unicode Response Crash
- Fixed an issue where the default encoding (Latin1) caused crashes when sending Unicode characters (like emojis π, β ) in responses.
- All response helpers (
json,html, etc.) now explicitly setcharset=utf-8in theContent-Typeheader by default.
2.0.2 - 2025-01-27 #
Added #
- Server-Sent Events (SSE) -
Response.sse()for real-time server-to-client streamingSSESinkclass withsendEvent(),sendComment(), keep-alive support- Example:
example/sse_example.dart
- Generic streaming -
Response.stream()for streaming files and data- Optional
flushEachChunkfor real-time delivery - Example:
example/stream_example.dart
- Optional
- Response utility -
Response.status()chainable status code setter - HEAD HTTP method - Added
RequestTypes.HEADconstant andhead()method- Available in
Fletch,IsolatedContainer, andBaseContainer
- Available in
- Integration tests for SSE and streaming (16 tests, all passing)
Changed #
- HTTP method refactoring - Moved HTTP method handlers to
BaseContainer- Eliminated code duplication between
FletchandIsolatedContainer - All HTTP methods (get, post, put, patch, delete, head, options) now inherited from base
IsolatedContaineroverridesaddRoute()for path normalization
- Eliminated code duplication between
Response.send()is nowFuture<void>(wasvoid) - all call sites updated toawait- Stream cleanup with try-finally blocks to prevent socket leaks
- Using
httpResponse.headers.chunkedTransferEncoding = trueinstead of manual headers - Mutual exclusion between
stream(),sse(), andbody/bytesresponses
Fixed #
- Unawaited futures in
base_container.dartandfletch.dart SSESink.sendComment()is nowFuture<void>for proper error propagation- Keep-alive errors using
unawaited()for fire-and-forget operations
2.0.1 - 2025-01-23 #
Documentation #
- Added Fletch logo to README with baseline alignment
- Improved README visual presentation
2.0.0 - 2025-01-22 #
π₯ BREAKING CHANGES - Complete Package Repurposing #
This package has been completely repurposed from a jQuery-like library to an Express-inspired HTTP framework.
Package History
- Versions 0.1.0 - 0.3.0 (2014): jQuery-like library by Rob Kellett
- Version 2.0.0 (2025): Express-inspired HTTP framework by Kartikey Mahawar
Thank you to Rob Kellett for graciously transferring the package name to enable this new project!
For Users of the Original Library (v0.3.0)
If you were using the jQuery-like library:
- Version 0.3.0 remains available: https://pub.flutter-io.cn/packages/fletch/versions/0.3.0
- Original repository: https://github.com/RobKellett/Fletch
- Pin your version in
pubspec.yaml:dependencies: fletch: 0.3.0
What's New in 2.0.0
This is a completely new HTTP framework with:
- Express-like API: Familiar
app.get(),app.post(), middleware patterns - Production-ready: HMAC-signed sessions, CORS, rate limiting
- Fast routing: Radix-tree router with path parameters
- Dependency injection: GetIt-powered DI container
- Modular design: Controllers, isolated containers
- Comprehensive docs: https://docs.fletch.mahawarkartikey.in/
Features #
- β Express-inspired routing and middleware
- β Built-in session management with HMAC signing
- β CORS and rate limiting middleware
- β
Request/response helpers (
req.params,res.json()) - β Error handling with custom error types
- β Graceful shutdown support
- β 98 passing tests
- β Full TypeScript-like type safety
Documentation #
- Homepage: https://docs.fletch.mahawarkartikey.in/
- GitHub: https://github.com/kartikey321/fletch
- Examples: See
/exampledirectory
0.3.0 - 2014-07-26 (Original Package by Rob Kellett) #
jQuery-like library for Dart. See original repository for details.
1.0.0 - 2024-12-13 (Internal Development Version) #
π Security Enhancements #
- Added HMAC-SHA256 session signing: Session cookies are now cryptographically signed to prevent tampering
- Changed session cookie defaults: Now use
secure: true,httpOnly: true,SameSite: Laxby default - Added constant-time signature comparison: Protection against timing attacks
- Fixed rate limiter memory leak: Cleanup timers now properly disposed on shutdown
β¨ New Features #
- Pluggable Session Stores: Abstract
SessionStoreinterface for custom persistence backends - MemorySessionStore: Built-in in-memory store with automatic TTL expiration
- Session lifecycle hooks: Automatic load/save with error handling
sessionSecretparameter: Configure HMAC secret for productionsecureCookiesparameter: Control HTTPS enforcement (default:true)sessionStoreparameter: Use Redis, PostgreSQL, or custom backends
π§ Bug Fixes #
- Fixed cookie parser discarding empty cookie values (e.g.,
logout=) - Fixed rate limiter cleanup timer memory leak
- Removed broken
Session.regenerate()method (session ID is immutable) - Added proper resource cleanup on server shutdown
π₯ BREAKING CHANGES #
- Session cookies now require HTTPS in production (default
secure: true)- Set
secureCookies: falsefor local HTTP development - Ensure HTTPS is configured for production deployments
- Set
Dependencies #
- Added:
crypto: ^3.0.3