Releases: iyifr/h4
v0.4.6
0.4.6
- Refactored
readRequestBodyutility, making it more efficient and less error prone. - Made
readRequestBodyutility generic for better typing, but didn't get very far using native types. - Added more tests for the
readRequestBodyutility.
The utility can now also handle FormData request bodies, but it is recommended to use readFormData or readFiles for the standard way of reading other data types from the request body.
The utility was also made generic for stronger typing but avoid using specific types directly e.g
// Will throw type error because casting doesn't work for complex types
List<Map<String, User>>? body = readRequestBody(event)
// Preferred
// You can then use a class to improve the type or use `fromJson` helpers
List<Map<String, dynamic>>? body = readRequestBody(event)v.0.4.4 (Patch)
-
OPTIMIZED Router implementation:
- Improved root path ('/') handling
- Simplified conditional logic in route handler with ternary expressions
- Removed support for '**' wildcard pattern
-
IMPROVED Test coverage:
- Added test for named routes
- Simplified wildcard route tests by removing redundant assertions
- Removed unnecessary status code checks
-
REFACTORED Internal code:
- Streamlined error handling logic in router
- Improved code readability with more concise syntax
v0.4.3 (Patch Release)
0.4.3 (Patch Release)
-
IMPROVED CORS handling with new
handleCorsutility:- Added support for credentials, max age, and custom headers
- Better documentation and examples for CORS configuration
- Default values for common CORS scenarios
-
ENHANCED IP address detection in
getRequestIp:- Added support for additional IP headers:
- X-Real-IP
- CF-Connecting-IP
- True-Client-IP
- Improved fallback chain for IP detection
- Added support for additional IP headers:
-
OPTIMIZED Router implementation:
- Improved param route scanning efficiency
- Better handling of root path ('/')
- Removed unused root handler parameter
-
IMPROVED Documentation:
- Added comprehensive examples for route parameters
- Enhanced documentation for request utilities
- Updated contributing guidelines
-
REFACTORED Internal utilities:
- Moved multipart form handling to private methods
- Better organization of request utilities
- Improved code readability and maintainability
v0.4.2
0.4.2 (Patch Release)
- EXTENDED
readFilesutility with new options for file handling:- Added
hashFileNameparameter (boolean) to control file name generation - Added
maxFileSizeparameter (int, MB) to limit upload sizes - Default values:
hashFileName: false,maxFileSize: 10
- Added
- IMPROVED Documentation for file upload functionality in README
- UPDATED Documentation comments for
readFilesutility with comprehensive examples and return
type details
v0.4.0
0.4.0 (Minor)
- NEW
readFilesutility to handle file uploads.
var files = await readFiles(event, fieldName: 'file', customFilePath: 'uploads');
// files is a List<Map<String, dynamic>> containing the info of the files uploaded.
// Example:
// [
// {
// 'path': 'uploads/test.txt',
// 'mimeType': 'text/plain',
// 'originalname': 'test.txt',
// 'fieldName': 'file',
// 'size': 17,
// 'tempFilename': 'test.txt'
// }
// ]
// EXAMPLE HANDLER.
router.post("/upload", (event) async {
var files = await readFiles(event, fieldName: 'file', customFilePath: 'uploads');
return files;
});- PATCHED
readFilesutility to handle file uploads better.
Full Changelog: v0.3.2...v0.4.0
Full Changelog: v0.3.2...v0.4.0
v0.3.2 (Patch CLI)
Patch Bug in CLI when you try to boostrap an APP and the name of your app has a _ in it's string.
v0.3.1
0.3.1 (Patch)
- EXTENDED
readFormDatautility to handle undefined formdata fields better. - PATCHED
setResponseHeaderutility to better handle immutable nature of http response
headers. - Documented some utilities better.
- Entire library is now accessible from one import.
v0.3.0
- NEW Multiple Routers with
basePath
void main() async {
var app = createApp(
port: 5173,
onRequest: (event) {
// PER REQUEST local state😻
event.context["user"] = 'Ogunlepon';
setResponseHeader(event,
header: HttpHeaders.contentTypeHeader,
value: 'text/html; charset=utf-8');
},
afterResponse: (event) => {},
);
var router = createRouter();
var apiRouter = createRouter();
app.use(router, basePath: '/');
app.use(apiRouter, basePath: '/api');
router.get("/vamos/:id/base/:studentId", (event) {
return event.params;
});
apiRouter.get("/signup", (event) async {
var formData = await readFormData(event);
var username = formData.get('username');
var password = formData.get('password');
// userService.signup(username, password);
event.statusCode = 201;
return 'Hi from /api with $username, $password';
});
}- NEW
readFormDatautility - familiar formdata parsing API
apiRouter.get("/signup", (event) async {
var formData = await readFormData(event);
var username = formData.get('username');
var password = formData.get('password');
// ALSO included..
var allNames = formdata.getAll('names') // return List<String>
userService.signup(username, password);
event.statusCode = 201;
return 'Hi from /api';
});-
NEW
getRequestIpandgetRequestOriginutilities -
PATCHED
H4Eventparams now correctly parses more than one param in the route string. e.g
'/user/:userId/profile/:projectId' -
PATCHED all bugs in the behaviour of param routes.
-
PATCHED
getRequestHeaderutility
v0.2.0
0.2.0
-
Minor Release
-
Improved CLI
- Added a new command H4 start which starts your app locally.
h4 start
or
dart pub global run h4:start
--dev flag
- Run the command with the --dev flag to restart the server when you make changes to your files
-
New Utilities
- getQuery
- setResponseHeader
- getHeader
-