diff --git a/README.md b/README.md index 9b1e25d6..094a661d 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ For more details, checkout [Project Status](https://github.com/dukefirehawk/ange * Added default logger to generate standardised logging messages * Added `melos` support * Removed deprecated API +* [**Breaking**] `error` for `AngelHttpException` is no longer mandatory ## Installation and Setup diff --git a/TODO.md b/TODO.md index 5bee6b2f..19035908 100644 --- a/TODO.md +++ b/TODO.md @@ -5,13 +5,10 @@ * Update examples * Update User Guide * Fix bugs - * `angel3_oauth2` failed test cases - * `angel3_proxy` failed test cases * `angel3_orm_mysql` ## Long Term Goal * Refactor Angel3 architecture for performance and security - * Better logging for error messages - * Improve exception and error handling * Improve ORM features + * Improve performances diff --git a/packages/cors/CHANGELOG.md b/packages/cors/CHANGELOG.md index 9633710e..6eff5fd0 100644 --- a/packages/cors/CHANGELOG.md +++ b/packages/cors/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.1 + +* Fixed analyze error + ## 6.0.0 * Updated to SDK 2.16.x diff --git a/packages/cors/lib/src/cors_options.dart b/packages/cors/lib/src/cors_options.dart index bcc22825..e6fb5aed 100644 --- a/packages/cors/lib/src/cors_options.dart +++ b/packages/cors/lib/src/cors_options.dart @@ -41,7 +41,7 @@ class CorsOptions { /// - `bool Function(String)` - set `origin` to a function implementing some custom logic. The function takes the request origin as the first parameter and returns a [bool]. /// /// Default: `'*'` - final origin; + final dynamic origin; /// If `false`, then the [cors] handler will terminate the response after performing its logic. /// diff --git a/packages/cors/pubspec.yaml b/packages/cors/pubspec.yaml index 091ec69e..425eb3f4 100644 --- a/packages/cors/pubspec.yaml +++ b/packages/cors/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_cors -version: 6.0.0 +version: 6.0.1 description: Angel3 CORS middleware. Ported from expressjs/cors to Angel3 framework. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/cors diff --git a/packages/http_exception/CHANGELOG.md b/packages/http_exception/CHANGELOG.md index 933006c7..b2b179dd 100644 --- a/packages/http_exception/CHANGELOG.md +++ b/packages/http_exception/CHANGELOG.md @@ -1,10 +1,14 @@ # Change Log +## 6.0.1 + +* Updated README + ## 6.0.0 * Updated to SDK 2.16.x -* Removed `error` +* [**Breaking**] `error` for `AngelHttpException` is no longer mandatory ## 5.0.0 diff --git a/packages/http_exception/lib/angel3_http_exception.dart b/packages/http_exception/lib/angel3_http_exception.dart index 094f3e77..e64a2016 100644 --- a/packages/http_exception/lib/angel3_http_exception.dart +++ b/packages/http_exception/lib/angel3_http_exception.dart @@ -12,7 +12,7 @@ class AngelHttpException implements Exception { /// A list of errors that occurred when this exception was thrown. final List errors = []; - /// The cause of this exception. + /// The error throw by exception. dynamic error; /// The cause of this exception. @@ -28,6 +28,7 @@ class AngelHttpException implements Exception { {this.message = '500 Internal Server Error', this.stackTrace, this.statusCode = 500, + this.error, List errors = const []}) { this.errors.addAll(errors); } diff --git a/packages/http_exception/pubspec.yaml b/packages/http_exception/pubspec.yaml index 25aa61ed..88624e49 100644 --- a/packages/http_exception/pubspec.yaml +++ b/packages/http_exception/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_http_exception -version: 6.0.0 +version: 6.0.1 description: Exception class that can be serialized to JSON and serialized to clients. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/http_exception diff --git a/packages/jael/jael_language_server/lib/jael3_language_server.dart b/packages/jael/jael_language_server/lib/jael3_language_server.dart index 23bc99ba..35137815 100644 --- a/packages/jael/jael_language_server/lib/jael3_language_server.dart +++ b/packages/jael/jael_language_server/lib/jael3_language_server.dart @@ -1 +1 @@ -export 'src/server.dart'; \ No newline at end of file +export 'src/server.dart'; diff --git a/packages/jael/jael_language_server/lib/src/protocol/language_server/messages.dart b/packages/jael/jael_language_server/lib/src/protocol/language_server/messages.dart index cd8e1147..180e6a3a 100644 --- a/packages/jael/jael_language_server/lib/src/protocol/language_server/messages.dart +++ b/packages/jael/jael_language_server/lib/src/protocol/language_server/messages.dart @@ -248,8 +248,7 @@ class CodeActionContext { final List? diagnostics; - Map toJson() => - {'diagnostics': diagnostics?.map((v) => v.toJson()).toList()}; + Map toJson() => {'diagnostics': diagnostics?.map((v) => v.toJson()).toList()}; @override int get hashCode { var hash = 698635161; @@ -966,10 +965,8 @@ class Diagnostics { final String? uri; - Map toJson() => { - 'diagnostics': diagnostics?.map((v) => v.toJson()).toList(), - 'uri': uri - }; + Map toJson() => + {'diagnostics': diagnostics?.map((v) => v.toJson()).toList(), 'uri': uri}; @override int get hashCode { var hash = 133599092; @@ -2916,7 +2913,7 @@ int _deepHashCode(dynamic value) { return (value.keys .map((key) => _hashCombine(key.hashCode, _deepHashCode(value[key]))) .toList(growable: false) - ..sort()) + ..sort()) .reduce(_hashCombine); } return value.hashCode; diff --git a/packages/oauth2/CHANGELOG.md b/packages/oauth2/CHANGELOG.md index 64e07646..3af4fe56 100644 --- a/packages/oauth2/CHANGELOG.md +++ b/packages/oauth2/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 6.0.1 + +* Fixed AngelHttpException error +* [Breaking] Renamed `error` to `authError` for `AuthorizationException` + ## 6.0.0 * Updated to SDK 2.16.x diff --git a/packages/oauth2/lib/src/exception.dart b/packages/oauth2/lib/src/exception.dart index 061c90b4..bae0499d 100644 --- a/packages/oauth2/lib/src/exception.dart +++ b/packages/oauth2/lib/src/exception.dart @@ -5,9 +5,12 @@ class AuthorizationException extends AngelHttpException { final ErrorResponse errorResponse; AuthorizationException(this.errorResponse, - {StackTrace? stackTrace, int? statusCode, error}) - : super(error ?? errorResponse, - stackTrace: stackTrace, message: '', statusCode: statusCode ?? 400); + {StackTrace? stackTrace, int? statusCode, dynamic error}) + : super( + stackTrace: stackTrace, + message: '', + //error: error, + statusCode: statusCode ?? 400); @override Map toJson() { diff --git a/packages/oauth2/pubspec.yaml b/packages/oauth2/pubspec.yaml index 0d8d8990..ca678d03 100644 --- a/packages/oauth2/pubspec.yaml +++ b/packages/oauth2/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_oauth2 -version: 6.0.0 +version: 6.0.1 description: A class containing handlers that can be used within Angel to build a spec-compliant OAuth 2.0 server. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/oauth2 diff --git a/packages/oauth2/test/auth_code_test.dart b/packages/oauth2/test/auth_code_test.dart index d8cd931c..c44cc904 100644 --- a/packages/oauth2/test/auth_code_test.dart +++ b/packages/oauth2/test/auth_code_test.dart @@ -19,7 +19,7 @@ void main() { setUp(() async { app = Angel(); app.configuration['properties'] = app.configuration; - app.container!.registerSingleton(AuthCodes()); + app.container.registerSingleton(AuthCodes()); var server = _Server(); diff --git a/packages/oauth2/test/pkce_test.dart b/packages/oauth2/test/pkce_test.dart index 806ef0a1..2c80d632 100644 --- a/packages/oauth2/test/pkce_test.dart +++ b/packages/oauth2/test/pkce_test.dart @@ -15,7 +15,7 @@ void main() { setUp(() async { app = Angel(); - app.container!.registerSingleton(AuthCodes()); + app.container.registerSingleton(AuthCodes()); var server = _Server(); diff --git a/packages/proxy/CHANGELOG.md b/packages/proxy/CHANGELOG.md index 8b363afc..29bc4748 100644 --- a/packages/proxy/CHANGELOG.md +++ b/packages/proxy/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.1 + +* Fixed exception errors + ## 6.0.0 * Updated to SDK 2.16.x diff --git a/packages/proxy/lib/src/proxy_layer.dart b/packages/proxy/lib/src/proxy_layer.dart index bd5055a2..447430d4 100644 --- a/packages/proxy/lib/src/proxy_layer.dart +++ b/packages/proxy/lib/src/proxy_layer.dart @@ -116,7 +116,7 @@ class Proxy { scheduleMicrotask(() => remote.pipe(local)); return false; } catch (e, st) { - throw AngelHttpException(e, + throw AngelHttpException( message: 'Could not connect WebSocket', stackTrace: st); } } @@ -167,7 +167,6 @@ class Proxy { if (recoverFromDead) return true; throw AngelHttpException( - e, stackTrace: st, statusCode: 504, message: @@ -189,7 +188,6 @@ class Proxy { if (recoverFromDead) return true; throw AngelHttpException( - e, stackTrace: st, statusCode: 504, message: 'Host "$uri" returned a malformed content-type', diff --git a/packages/proxy/pubspec.yaml b/packages/proxy/pubspec.yaml index c62b0039..301f365c 100644 --- a/packages/proxy/pubspec.yaml +++ b/packages/proxy/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_proxy -version: 6.0.0 +version: 6.0.1 description: Angel middleware to forward requests to another server (i.e. pub serve). homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/proxy diff --git a/packages/proxy/test/common.dart b/packages/proxy/test/common.dart index 675c15e3..44b01432 100644 --- a/packages/proxy/test/common.dart +++ b/packages/proxy/test/common.dart @@ -12,7 +12,7 @@ Future startTestServer() { app.get('/foo/bar', (req, res) => res.write('baz')); app.post('/body', (RequestContext req, res) async { var body = await req.parseBody().then((_) => req.bodyAsMap); - app.logger!.info('Body: $body'); + app.logger.info('Body: $body'); return body; }); diff --git a/packages/route/test/params_test.dart b/packages/route/test/params_test.dart index 34783de8..3110ae8f 100644 --- a/packages/route/test/params_test.dart +++ b/packages/route/test/params_test.dart @@ -2,7 +2,9 @@ import 'package:angel3_route/angel3_route.dart'; import 'package:test/test.dart'; void main() { - final router = Router()..get('/hello', '')..get('/user/:id', ''); + final router = Router() + ..get('/hello', '') + ..get('/user/:id', ''); router.group('/book/:id', (router) { router.get('/reviews', ''); diff --git a/packages/security/CHANGELOG.md b/packages/security/CHANGELOG.md index b860569c..f216b271 100644 --- a/packages/security/CHANGELOG.md +++ b/packages/security/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.1 + +* Fixed AngelHttpException error + ## 6.0.0 * Updated to SDK 2.16.x diff --git a/packages/security/example/cookie_signer.dart b/packages/security/example/cookie_signer.dart index 16d0d9ad..e83e127f 100644 --- a/packages/security/example/cookie_signer.dart +++ b/packages/security/example/cookie_signer.dart @@ -38,7 +38,7 @@ void main() async { // here we will use it to log invalid cookies. app.get('/cookies', (req, res) { var verifiedCookies = signer.readCookies(req, onInvalidCookie: (cookie) { - app.logger!.warning('Invalid cookie: $cookie'); + app.logger.warning('Invalid cookie: $cookie'); }); res.writeln('${verifiedCookies.length} verified cookie(s)'); res.writeln('${req.cookies.length} total unverified cookie(s)'); diff --git a/packages/security/lib/src/rate_limiter.dart b/packages/security/lib/src/rate_limiter.dart index 357db2ba..f141d25a 100644 --- a/packages/security/lib/src/rate_limiter.dart +++ b/packages/security/lib/src/rate_limiter.dart @@ -85,7 +85,7 @@ abstract class RateLimiter { RateLimitingWindow window, DateTime currentTime) { var retryAfter = window.resetTime!.difference(currentTime); res.headers['retry-after'] = retryAfter.inSeconds.toString(); - throw AngelHttpException(null, message: errorMessage, statusCode: 429); + throw AngelHttpException(message: errorMessage, statusCode: 429); } /// A request middleware that returns `true` if the user has not yet diff --git a/packages/security/pubspec.yaml b/packages/security/pubspec.yaml index 88c4f59a..a63b41c3 100644 --- a/packages/security/pubspec.yaml +++ b/packages/security/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_security -version: 6.0.0 +version: 6.0.1 description: Angel3 infrastructure for improving security, rate limiting, and more homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/security diff --git a/packages/shelf/CHANGELOG.md b/packages/shelf/CHANGELOG.md index 3bfd2188..34bb9495 100644 --- a/packages/shelf/CHANGELOG.md +++ b/packages/shelf/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.0-beta.2 + +* Fixed AngelHttpException error + ## 6.0.0-beta.1 * Updated to SDK 2.16.x diff --git a/packages/shelf/lib/src/convert.dart b/packages/shelf/lib/src/convert.dart index 457fa695..9f23a23a 100644 --- a/packages/shelf/lib/src/convert.dart +++ b/packages/shelf/lib/src/convert.dart @@ -48,7 +48,7 @@ Future convertRequest(RequestContext req, ResponseContext res, hijack(ctrl.foreign); } catch (e, st) { app?.logger - ?.severe('An error occurred while hijacking a shelf request', e, st); + .severe('An error occurred while hijacking a shelf request', e, st); } }; diff --git a/packages/shelf/lib/src/embed_shelf.dart b/packages/shelf/lib/src/embed_shelf.dart index 1f7faf75..b84bb5e7 100644 --- a/packages/shelf/lib/src/embed_shelf.dart +++ b/packages/shelf/lib/src/embed_shelf.dart @@ -19,9 +19,8 @@ RequestHandler embedShelf(shelf.Handler handler, handlerPath: handlerPath, context: context); try { var result = await handler(shelfRequest); - if (result is! shelf.Response) return result; if (throwOnNullResponse == true) { - throw AngelHttpException('Internal Server Error'); + throw AngelHttpException(message: 'Internal Server Error'); } await mergeShelfResponse(result, res); return false; diff --git a/packages/shelf/lib/src/shelf_driver.dart b/packages/shelf/lib/src/shelf_driver.dart index 2775bfb7..64ef637c 100644 --- a/packages/shelf/lib/src/shelf_driver.dart +++ b/packages/shelf/lib/src/shelf_driver.dart @@ -6,9 +6,8 @@ import 'package:shelf/shelf.dart'; import 'shelf_request.dart'; import 'shelf_response.dart'; -// TODO: To be reviewed Future> process(dynamic param1, int param2) { - return Future.value(); + return Future.value(Stream.empty()); } class AngelShelf extends Driver