Updated to 6.0.0

This commit is contained in:
thomashii 2022-02-14 00:48:37 +08:00
parent bab4e5eaf6
commit dfd974c106
21 changed files with 124 additions and 52 deletions

View file

@ -1,5 +1,18 @@
# Change Log # Change Log
## 6.0.0
* Updated to min SDK 2.15.x
* Removed `error`
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.1.1 ## 3.1.1
* Updated `_ReflectedMethodMirror` to have optional `returnType` parameter * Updated `_ReflectedMethodMirror` to have optional `returnType` parameter

View file

@ -1,10 +1,10 @@
name: angel3_container name: angel3_container
version: 3.1.1 version: 6.0.0
description: Angel3 hierarchical DI container, and pluggable backends for reflection. description: Angel3 hierarchical DI container, and pluggable backends for reflection.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.15.0 <3.0.0'
dependencies: dependencies:
collection: ^1.15.0 collection: ^1.15.0
quiver: ^3.0.1 quiver: ^3.0.1

View file

@ -1,5 +1,13 @@
# Change Log # Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.0.0
* No release. Skipped
## 4.2.4 ## 4.2.4
* Fixed issue 48. Log not working in development * Fixed issue 48. Log not working in development
@ -356,7 +364,7 @@ stable, there'll be a conversion, perhaps.
* `Routable`, and all of its subclasses, now extend `Router<RequestHandler>`, and therefore only * `Routable`, and all of its subclasses, now extend `Router<RequestHandler>`, and therefore only
take routes in the form of `FutureOr myFunc(RequestContext, ResponseContext res)`. take routes in the form of `FutureOr myFunc(RequestContext, ResponseContext res)`.
* `@Middleware` now takes an `Iterable` of `RequestHandler`s. * `@Middleware` now takes an `Iterable` of `RequestHandler`s.
* `@Expose.path` now _must_ be a `String`, not just any `Pattern`. * `@Expose.path` now *must* be a `String`, not just any `Pattern`.
* `@Expose.middleware` now takes `Iterable<RequestHandler>`, instead of just `List`. * `@Expose.middleware` now takes `Iterable<RequestHandler>`, instead of just `List`.
* `createDynamicHandler` was renamed to `ioc`, and is now used to run IoC-aware handlers in a * `createDynamicHandler` was renamed to `ioc`, and is now used to run IoC-aware handlers in a
type-safe manner. type-safe manner.

View file

@ -185,7 +185,7 @@ abstract class Driver<
throw AngelHttpException.badRequest(message: e.message) throw AngelHttpException.badRequest(message: e.message)
..stackTrace = st; ..stackTrace = st;
} }
throw AngelHttpException(e, throw AngelHttpException(
stackTrace: st, stackTrace: st,
statusCode: (e is AngelHttpException) ? e.statusCode : 500, statusCode: (e is AngelHttpException) ? e.statusCode : 500,
message: e?.toString() ?? '500 Internal Server Error'); message: e?.toString() ?? '500 Internal Server Error');
@ -198,7 +198,7 @@ abstract class Driver<
if (ee is AngelHttpException) { if (ee is AngelHttpException) {
e = ee; e = ee;
} else { } else {
e = AngelHttpException(ee, e = AngelHttpException(
stackTrace: st, stackTrace: st,
statusCode: 500, statusCode: 500,
message: ee?.toString() ?? '500 Internal Server Error'); message: ee?.toString() ?? '500 Internal Server Error');
@ -233,7 +233,7 @@ abstract class Driver<
} else if (error is AngelHttpException) { } else if (error is AngelHttpException) {
e = error; e = error;
} else { } else {
e = AngelHttpException(error, e = AngelHttpException(
stackTrace: stackTrace, message: error.toString()); stackTrace: stackTrace, message: error.toString());
} }

View file

@ -1,5 +1,5 @@
name: angel3_framework name: angel3_framework
version: 4.2.4 version: 6.0.0
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more. description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework
@ -38,3 +38,11 @@ dev_dependencies:
dependency_overrides: dependency_overrides:
angel3_container: angel3_container:
path: ../container/angel_container path: ../container/angel_container
angel3_http_exception:
path: ../http_exception
angel3_model:
path: ../model
angel3_route:
path: ../route
angel3_mock_request:
path: ../mock_request

View file

@ -1,6 +1,5 @@
import 'package:angel3_framework/angel3_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:matcher/matcher.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
void main() { void main() {
@ -41,9 +40,7 @@ void main() {
}); });
test('toString', () { test('toString', () {
expect( expect(AngelHttpException(statusCode: 420, message: 'Blaze It').toString(),
AngelHttpException(null, statusCode: 420, message: 'Blaze It')
.toString(),
'420: Blaze It'); '420: Blaze It');
}); });
} }

View file

@ -5,7 +5,6 @@ import 'dart:io';
import 'package:angel3_container/mirrors.dart'; import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart'; import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart'; import 'package:angel3_framework/http.dart';
import 'package:matcher/matcher.dart';
import 'package:angel3_mock_request/angel3_mock_request.dart'; import 'package:angel3_mock_request/angel3_mock_request.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
@ -46,7 +45,7 @@ void main() {
var rs = rq.response; var rs = rq.response;
var req = await http.createRequestContext(rq, rs); var req = await http.createRequestContext(rq, rs);
var res = await http.createResponseContext(rq, rs); var res = await http.createResponseContext(rq, rs);
var e = AngelHttpException(null, var e = AngelHttpException(
statusCode: 321, message: 'Hello', errors: ['foo', 'bar']); statusCode: 321, message: 'Hello', errors: ['foo', 'bar']);
await app.errorHandler(e, req, res); await app.errorHandler(e, req, res);
await http.sendResponse(rq, rs, req, res); await http.sendResponse(rq, rs, req, res);

View file

@ -1,6 +1,19 @@
# Change Log # Change Log
## 6.0.0
* Updated to min SDK 2.15.x
* Removed `error`
## 5.0.0
* Skipped release
## 4.0.0
* Skipped release
## 3.1.0 ## 3.1.0
* Upgraded to `lints` linter * Upgraded to `lints` linter

View file

@ -9,11 +9,12 @@ import 'dart:convert';
/// Originally inspired by /// Originally inspired by
/// [feathers-errors](https://github.com/feathersjs/feathers-errors). /// [feathers-errors](https://github.com/feathersjs/feathers-errors).
class AngelHttpException implements Exception { class AngelHttpException implements Exception {
var error;
/// A list of errors that occurred when this exception was thrown. /// A list of errors that occurred when this exception was thrown.
final List<String> errors = []; final List<String> errors = [];
/// The cause of this exception.
dynamic error;
/// The cause of this exception. /// The cause of this exception.
String message; String message;
@ -23,7 +24,7 @@ class AngelHttpException implements Exception {
/// An HTTP status code this exception will throw. /// An HTTP status code this exception will throw.
int statusCode; int statusCode;
AngelHttpException(this.error, AngelHttpException(
{this.message = '500 Internal Server Error', {this.message = '500 Internal Server Error',
this.stackTrace, this.stackTrace,
this.statusCode = 500, this.statusCode = 500,
@ -49,7 +50,6 @@ class AngelHttpException implements Exception {
factory AngelHttpException.fromMap(Map data) { factory AngelHttpException.fromMap(Map data) {
return AngelHttpException( return AngelHttpException(
null,
statusCode: (data['status_code'] ?? data['statusCode'] ?? 500) as int, statusCode: (data['status_code'] ?? data['statusCode'] ?? 500) as int,
message: data['message']?.toString() ?? 'Internal Server Error', message: data['message']?.toString() ?? 'Internal Server Error',
errors: data['errors'] is Iterable errors: data['errors'] is Iterable
@ -66,57 +66,56 @@ class AngelHttpException implements Exception {
factory AngelHttpException.badRequest( factory AngelHttpException.badRequest(
{String message = '400 Bad Request', {String message = '400 Bad Request',
List<String> errors = const []}) => List<String> errors = const []}) =>
AngelHttpException(null, AngelHttpException(message: message, errors: errors, statusCode: 400);
message: message, errors: errors, statusCode: 400);
/// Throws a 401 Not Authenticated error. /// Throws a 401 Not Authenticated error.
factory AngelHttpException.notAuthenticated( factory AngelHttpException.notAuthenticated(
{String message = '401 Not Authenticated'}) => {String message = '401 Not Authenticated'}) =>
AngelHttpException(null, message: message, statusCode: 401); AngelHttpException(message: message, statusCode: 401);
/// Throws a 402 Payment Required error. /// Throws a 402 Payment Required error.
factory AngelHttpException.paymentRequired( factory AngelHttpException.paymentRequired(
{String message = '402 Payment Required'}) => {String message = '402 Payment Required'}) =>
AngelHttpException(null, message: message, statusCode: 402); AngelHttpException(message: message, statusCode: 402);
/// Throws a 403 Forbidden error. /// Throws a 403 Forbidden error.
factory AngelHttpException.forbidden({String message = '403 Forbidden'}) => factory AngelHttpException.forbidden({String message = '403 Forbidden'}) =>
AngelHttpException(null, message: message, statusCode: 403); AngelHttpException(message: message, statusCode: 403);
/// Throws a 404 Not Found error. /// Throws a 404 Not Found error.
factory AngelHttpException.notFound({String message = '404 Not Found'}) => factory AngelHttpException.notFound({String message = '404 Not Found'}) =>
AngelHttpException(null, message: message, statusCode: 404); AngelHttpException(message: message, statusCode: 404);
/// Throws a 405 Method Not Allowed error. /// Throws a 405 Method Not Allowed error.
factory AngelHttpException.methodNotAllowed( factory AngelHttpException.methodNotAllowed(
{String message = '405 Method Not Allowed'}) => {String message = '405 Method Not Allowed'}) =>
AngelHttpException(null, message: message, statusCode: 405); AngelHttpException(message: message, statusCode: 405);
/// Throws a 406 Not Acceptable error. /// Throws a 406 Not Acceptable error.
factory AngelHttpException.notAcceptable( factory AngelHttpException.notAcceptable(
{String message = '406 Not Acceptable'}) => {String message = '406 Not Acceptable'}) =>
AngelHttpException(null, message: message, statusCode: 406); AngelHttpException(message: message, statusCode: 406);
/// Throws a 408 Timeout error. /// Throws a 408 Timeout error.
factory AngelHttpException.methodTimeout({String message = '408 Timeout'}) => factory AngelHttpException.methodTimeout({String message = '408 Timeout'}) =>
AngelHttpException(null, message: message, statusCode: 408); AngelHttpException(message: message, statusCode: 408);
/// Throws a 409 Conflict error. /// Throws a 409 Conflict error.
factory AngelHttpException.conflict({String message = '409 Conflict'}) => factory AngelHttpException.conflict({String message = '409 Conflict'}) =>
AngelHttpException(null, message: message, statusCode: 409); AngelHttpException(message: message, statusCode: 409);
/// Throws a 422 Not Processable error. /// Throws a 422 Not Processable error.
factory AngelHttpException.notProcessable( factory AngelHttpException.notProcessable(
{String message = '422 Not Processable'}) => {String message = '422 Not Processable'}) =>
AngelHttpException(null, message: message, statusCode: 422); AngelHttpException(message: message, statusCode: 422);
/// Throws a 501 Not Implemented error. /// Throws a 501 Not Implemented error.
factory AngelHttpException.notImplemented( factory AngelHttpException.notImplemented(
{String message = '501 Not Implemented'}) => {String message = '501 Not Implemented'}) =>
AngelHttpException(null, message: message, statusCode: 501); AngelHttpException(message: message, statusCode: 501);
/// Throws a 503 Unavailable error. /// Throws a 503 Unavailable error.
factory AngelHttpException.unavailable( factory AngelHttpException.unavailable(
{String message = '503 Unavailable'}) => {String message = '503 Unavailable'}) =>
AngelHttpException(null, message: message, statusCode: 503); AngelHttpException(message: message, statusCode: 503);
} }

View file

@ -1,9 +1,9 @@
name: angel3_http_exception name: angel3_http_exception
version: 3.1.0 version: 6.0.0
description: Exception class that can be serialized to JSON and serialized to clients. description: Exception class that can be serialized to JSON and serialized to clients.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/http_exception repository: https://github.com/dukefirehawk/angel/tree/master/packages/http_exception
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.15.0 <3.0.0'
dev_dependencies: dev_dependencies:
lints: ^1.0.0 lints: ^1.0.0

View file

@ -1,5 +1,21 @@
# Change Log # Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.0.0
* No release. Skipped
## 4.0.0
* No release. Skipped
## 3.0.0
* No release. Skipped
## 2.1.0 ## 2.1.0
* Updated linter to `package:lints` * Updated linter to `package:lints`

View file

@ -94,8 +94,8 @@ class MockHttpHeaders extends HttpHeaders {
} }
@override @override
void forEach(void Function(String name, List<String> values) f) { void forEach(void Function(String name, List<String> values) action) {
_data.forEach(f); _data.forEach(action);
} }
@override @override

View file

@ -40,8 +40,8 @@ class MockHttpSession extends MapBase implements HttpSession {
} }
@override @override
void forEach(void Function(dynamic, dynamic) f) { void forEach(void Function(dynamic, dynamic) action) {
_data.forEach(f); _data.forEach(action);
} }
@override @override

View file

@ -1,10 +1,10 @@
name: angel3_mock_request name: angel3_mock_request
version: 2.1.0 version: 6.0.0
description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.15.0 <3.0.0'
dependencies: dependencies:
charcode: ^1.2.0 charcode: ^1.2.0
dev_dependencies: dev_dependencies:
@ -12,3 +12,6 @@ dev_dependencies:
http: ^0.13.2 http: ^0.13.2
test: ^1.17.4 test: ^1.17.4
lints: ^1.0.0 lints: ^1.0.0
dependency_overrides:
angel3_framework:
path: ../framework

View file

@ -1,5 +1,17 @@
# Change Log # Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.0.0
* No release. Skipped
## 4.0.0
* No release. Skipped
## 3.1.1 ## 3.1.1
* Removed `error` * Removed `error`

View file

@ -1,9 +1,9 @@
name: angel3_model name: angel3_model
version: 3.1.1 version: 6.0.0
description: Angel3 basic data model class, no longer with the added weight of the whole framework. description: Angel3 basic data model class, no longer with the added weight of the whole framework.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/model repository: https://github.com/dukefirehawk/angel/tree/master/packages/model
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.15.0 <3.0.0'
dev_dependencies: dev_dependencies:
lints: ^1.0.0 lints: ^1.0.0

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 6.0.0
* Updated to min SDK 2.15.x
## 5.2.0 ## 5.2.0
* Updated `package:build_runner` * Updated `package:build_runner`

View file

@ -101,9 +101,9 @@ Supports both hashed routes and pushState. The `BrowserRouter` interface exposes
To prevent this for a given anchor, do any of the following: To prevent this for a given anchor, do any of the following:
* Do not provide an `href` - Do not provide an `href`
* Provide a `download` or `target` attribute on the element - Provide a `download` or `target` attribute on the element
* Set `rel="external"` - Set `rel="external"`
## Route State ## Route State

View file

@ -4,10 +4,10 @@ import 'router.dart';
class MiddlewarePipeline<T> { class MiddlewarePipeline<T> {
/// All the possible routes that matched the given path. /// All the possible routes that matched the given path.
final Iterable<RoutingResult<T>> routingResults; final Iterable<RoutingResult<T>> routingResults;
final List<T?> _handlers = []; final List<T> _handlers = [];
/// An ordered list of every handler delegated to handle this request. /// An ordered list of every handler delegated to handle this request.
List<T?> get handlers { List<T> get handlers {
/* /*
if (_handlers != null) return _handlers; if (_handlers != null) return _handlers;
final handlers = <T>[]; final handlers = <T>[];

View file

@ -101,7 +101,7 @@ class Router<T> {
for (var route in routes) { for (var route in routes) {
if (route is! SymlinkRoute<T>) { if (route is! SymlinkRoute<T>) {
router._routes.add(route.clone()); router._routes.add(route.clone());
} else if (route is SymlinkRoute<T>) { } else {
final newRouter = route.router.clone(); final newRouter = route.router.clone();
newMounted[route.path] = newRouter; newMounted[route.path] = newRouter;
final symlink = SymlinkRoute<T>(route.path, newRouter); final symlink = SymlinkRoute<T>(route.path, newRouter);
@ -141,7 +141,7 @@ class Router<T> {
indent(); indent();
buf.write('- '); buf.write('- ');
if (route is! SymlinkRoute) buf.write('${route.method} '); if (route is! SymlinkRoute) buf.write('${route.method} ');
buf.write('${route.path.isNotEmpty ? route.path : '/'}'); buf.write(route.path.isNotEmpty ? route.path : '/');
if (route is SymlinkRoute<T>) { if (route is SymlinkRoute<T>) {
buf.writeln(); buf.writeln();

View file

@ -1,10 +1,10 @@
name: angel3_route name: angel3_route
version: 5.2.0 version: 6.0.0
description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel framework, but can be used in Flutter and on the Web. description: A powerful, isomorphic routing library for Dart. It is mainly used in the Angel3 framework, but can be used in Flutter and on the Web.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/route repository: https://github.com/dukefirehawk/angel/tree/master/packages/route
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.15.0 <3.0.0'
dependencies: dependencies:
belatuk_combinator: ^3.0.0 belatuk_combinator: ^3.0.0
string_scanner: ^1.1.0 string_scanner: ^1.1.0
@ -13,5 +13,5 @@ dev_dependencies:
build_runner: ^2.1.2 build_runner: ^2.1.2
build_web_compilers: ^3.2.1 build_web_compilers: ^3.2.1
http: ^0.13.3 http: ^0.13.3
test: ^1.17.5 test: ^1.20.0
lints: ^1.0.0 lints: ^1.0.0