From 3b9092d4df32bfad5ede51f908db8f4ae2a8d54a Mon Sep 17 00:00:00 2001 From: thomashii Date: Mon, 4 Oct 2021 13:13:56 +0800 Subject: [PATCH] Fixed requireAuthentication --- packages/auth/CHANGELOG.md | 4 + packages/auth/lib/src/plugin.dart | 16 ++-- packages/auth/pubspec.yaml | 10 ++- packages/auth_oauth2/.idea/auth_oauth2.iml | 16 ---- packages/auth_oauth2/.idea/modules.xml | 8 -- .../runConfigurations/Github_Auth_Server.xml | 7 -- packages/auth_oauth2/.idea/vcs.xml | 6 -- packages/auth_oauth2/README.md | 2 +- packages/auth_oauth2/pubspec.yaml | 4 - packages/auth_twitter/CHANGELOG.md | 15 +++- packages/auth_twitter/README.md | 12 ++- packages/auth_twitter/analysis_options.yaml | 5 +- packages/auth_twitter/pubspec.yaml | 12 +-- packages/client/pubspec.yaml | 4 - .../container/angel_container/CHANGELOG.md | 1 + .../angel_container/example/main.dart | 12 +-- .../angel_container/lib/src/container.dart | 84 ++++++++++++------- .../container/angel_container/pubspec.yaml | 2 +- .../angel_container/test/common.dart | 2 +- .../angel_container/test/has_test.dart | 3 +- .../angel_container/test/named_test.dart | 2 +- .../angel_container_generator/CHANGELOG.md | 4 + .../example/main.dart | 12 +-- .../angel_container_generator/pubspec.yaml | 6 +- .../test/reflector_test.dart | 4 +- packages/framework/CHANGELOG.md | 8 +- packages/framework/lib/src/core/driver.dart | 9 +- .../lib/src/core/response_context.dart | 8 +- packages/framework/lib/src/core/server.dart | 9 +- packages/framework/pubspec.yaml | 8 +- packages/framework/test/di_test.dart | 2 +- packages/production/pubspec.yaml | 3 - packages/shelf/pubspec.yaml | 3 - packages/test/pubspec.yaml | 5 +- packages/websocket/CHANGELOG.md | 6 +- packages/websocket/lib/server.dart | 2 +- packages/websocket/pubspec.yaml | 12 ++- 37 files changed, 167 insertions(+), 161 deletions(-) delete mode 100644 packages/auth_oauth2/.idea/auth_oauth2.iml delete mode 100644 packages/auth_oauth2/.idea/modules.xml delete mode 100644 packages/auth_oauth2/.idea/runConfigurations/Github_Auth_Server.xml delete mode 100644 packages/auth_oauth2/.idea/vcs.xml diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index d15a177a..9c503c7b 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.1.2 + +* Fixed `requireAuthentication` to work correctly with null-safety type + ## 4.1.1 * Changed `userId` field of `AuthToken` to String type diff --git a/packages/auth/lib/src/plugin.dart b/packages/auth/lib/src/plugin.dart index d37e794c..25831f8d 100644 --- a/packages/auth/lib/src/plugin.dart +++ b/packages/auth/lib/src/plugin.dart @@ -125,10 +125,10 @@ class AngelAuth { .registerLazySingleton>>((container) async { var req = container.make(); var res = container.make(); - if (req == null || res == null) { - _log.warning('RequestContext or responseContext is null'); - throw AngelHttpException.forbidden(); - } + //if (req == null || res == null) { + // _log.warning('RequestContext or responseContext is null'); + // throw AngelHttpException.forbidden(); + //} var result = await _decodeJwt(req, res); if (result != null) { @@ -139,14 +139,14 @@ class AngelAuth { } }); - appContainer.registerLazySingleton>((container) async { + appContainer.registerLazySingleton>((container) async { var result = await container.makeAsync<_AuthResult>(); - return result?.user; + return result.user; }); - appContainer.registerLazySingleton>((container) async { + appContainer.registerLazySingleton>((container) async { var result = await container.makeAsync<_AuthResult>(); - return result?.token; + return result.token; }); } diff --git a/packages/auth/pubspec.yaml b/packages/auth/pubspec.yaml index d30fd1e2..1154a2ab 100644 --- a/packages/auth/pubspec.yaml +++ b/packages/auth/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_auth description: A complete authentication plugin for Angel3. Includes support for stateless JWT tokens, Basic Auth, and more. -version: 4.1.1 +version: 4.1.2 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/auth environment: @@ -20,6 +20,8 @@ dev_dependencies: io: ^1.0.0 test: ^1.17.4 lints: ^1.0.0 -#dependency_overrides: -# angel3_framework: -# path: ../framework +dependency_overrides: + angel3_container: + path: ../container/angel_container + angel3_framework: + path: ../framework diff --git a/packages/auth_oauth2/.idea/auth_oauth2.iml b/packages/auth_oauth2/.idea/auth_oauth2.iml deleted file mode 100644 index eae13016..00000000 --- a/packages/auth_oauth2/.idea/auth_oauth2.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/auth_oauth2/.idea/modules.xml b/packages/auth_oauth2/.idea/modules.xml deleted file mode 100644 index afb47af5..00000000 --- a/packages/auth_oauth2/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/packages/auth_oauth2/.idea/runConfigurations/Github_Auth_Server.xml b/packages/auth_oauth2/.idea/runConfigurations/Github_Auth_Server.xml deleted file mode 100644 index d3ff1581..00000000 --- a/packages/auth_oauth2/.idea/runConfigurations/Github_Auth_Server.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/auth_oauth2/.idea/vcs.xml b/packages/auth_oauth2/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/packages/auth_oauth2/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/packages/auth_oauth2/README.md b/packages/auth_oauth2/README.md index 94ec4382..499dfefd 100644 --- a/packages/auth_oauth2/README.md +++ b/packages/auth_oauth2/README.md @@ -1,7 +1,7 @@ # Angel3 OAuth2 Handler ![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_auth_oauth2?include_prereleases) -![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)]() +![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)() [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) [![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/auth_oauth2/LICENSE) diff --git a/packages/auth_oauth2/pubspec.yaml b/packages/auth_oauth2/pubspec.yaml index 6028c0a8..e20d75d4 100644 --- a/packages/auth_oauth2/pubspec.yaml +++ b/packages/auth_oauth2/pubspec.yaml @@ -13,7 +13,3 @@ dependencies: dev_dependencies: logging: ^1.0.1 lints: ^1.0.0 -#dependency_overrides: -# angel3_auth: -# path: ../auth - \ No newline at end of file diff --git a/packages/auth_twitter/CHANGELOG.md b/packages/auth_twitter/CHANGELOG.md index ad8f7b0d..1f334f38 100644 --- a/packages/auth_twitter/CHANGELOG.md +++ b/packages/auth_twitter/CHANGELOG.md @@ -1,5 +1,16 @@ -# 2.0.0 +# Change Log + +## 4.0.0 + +* Migrated to support Dart SDK 2.12.x NNBD + +## 3.0.0 + +* Migrated to work with Dart SDK 2.12.x Non NNBD + +## 2.0.0 + * Angel 2 + Dart 2 suppport. * Use `package:twitter` instead of `package:twit`. * Add `TwitterAuthorizationException`. -* Add `onError` callback. \ No newline at end of file +* Add `onError` callback. diff --git a/packages/auth_twitter/README.md b/packages/auth_twitter/README.md index 6ce85ccb..dd4aef05 100644 --- a/packages/auth_twitter/README.md +++ b/packages/auth_twitter/README.md @@ -1,4 +1,10 @@ -# auth_twitter -angel_auth strategy for Twitter login. +# Angel3 Auth Twitter -See the [example](example/server.dart); \ No newline at end of file +![Pub Version (including pre-releases)](https://img.shields.io/pub/v/angel3_auth_twitter?include_prereleases) +![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)]() +[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) +[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/auth_twitter/LICENSE) + +Angel3 authentication strategy for Twitter login. + +See the [example](example/server.dart); diff --git a/packages/auth_twitter/analysis_options.yaml b/packages/auth_twitter/analysis_options.yaml index c230cee7..ea2c9e94 100644 --- a/packages/auth_twitter/analysis_options.yaml +++ b/packages/auth_twitter/analysis_options.yaml @@ -1,4 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/auth_twitter/pubspec.yaml b/packages/auth_twitter/pubspec.yaml index ddd44c9f..2ba132bd 100644 --- a/packages/auth_twitter/pubspec.yaml +++ b/packages/auth_twitter/pubspec.yaml @@ -1,21 +1,13 @@ -name: "angel_auth_twitter" +name: "angel3_auth_twitter" version: 3.0.0 -description: "package:angel_auth strategy for Twitter login. Auto-signs requests." +description: "package:angel3_auth strategy for Twitter login. Auto-signs requests." homepage: "https://github.com/angel-dart/auth_twitter.git" publish_to: none environment: sdk: ">=2.10.0 <3.0.0" dependencies: angel_auth: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x - path: packages/auth angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x - path: packages/framework http: ^0.13.0 path: ^1.0.0 twitter: diff --git a/packages/client/pubspec.yaml b/packages/client/pubspec.yaml index a53451d4..69748ef2 100644 --- a/packages/client/pubspec.yaml +++ b/packages/client/pubspec.yaml @@ -24,7 +24,3 @@ dev_dependencies: build_web_compilers: ^3.2.1 test: ^1.17.5 lints: ^1.0.0 -#dependency_overrides: -# angel3_auth: -# path: ../auth - \ No newline at end of file diff --git a/packages/container/angel_container/CHANGELOG.md b/packages/container/angel_container/CHANGELOG.md index 80a6e372..014cd1d6 100644 --- a/packages/container/angel_container/CHANGELOG.md +++ b/packages/container/angel_container/CHANGELOG.md @@ -3,6 +3,7 @@ ## 3.1.1 * Updated `_ReflectedMethodMirror` to have optional `returnType` parameter +* Updated all the methods of `Container` class to return non nullable type ## 3.1.0 diff --git a/packages/container/angel_container/example/main.dart b/packages/container/angel_container/example/main.dart index 632e34bb..abc4e97c 100644 --- a/packages/container/angel_container/example/main.dart +++ b/packages/container/angel_container/example/main.dart @@ -17,7 +17,7 @@ Future main() async { // Register a factory that creates a truck. container.registerFactory((container) { - return _TruckImpl(container.make()!); + return _TruckImpl(container.make()); }); // Use `make` to create an instance. @@ -28,16 +28,16 @@ Future main() async { print(await container.makeAsync()); // Asynchronous resolution also works for plain objects. - await container.makeAsync()?.then((t) => t.drive()); + await container.makeAsync().then((t) => t.drive()); // Register a named singleton. container.registerNamedSingleton('the_truck', truck); // Should print: 'Vroom! I have 40 horsepower in my engine.' - truck?.drive(); + truck.drive(); // Should print the same. - container.findByName('the_truck')?.drive(); + container.findByName('the_truck').drive(); // We can make a child container with its own factory. var childContainer = container.createChild(); @@ -47,10 +47,10 @@ Future main() async { }); // Make a truck with 5666 HP. - childContainer.make()?.drive(); + childContainer.make().drive(); // However, calling `make` will return the Engine singleton we created above. - print(childContainer.make()?.horsePower); + print(childContainer.make().horsePower); } abstract class Truck { diff --git a/packages/container/angel_container/lib/src/container.dart b/packages/container/angel_container/lib/src/container.dart index 54de7710..7dfd524c 100644 --- a/packages/container/angel_container/lib/src/container.dart +++ b/packages/container/angel_container/lib/src/container.dart @@ -23,14 +23,19 @@ class Container { } /// Determines if the container has an injection of the given type. - bool has([Type? t]) { - Container? search = this; - t ??= T == dynamic ? t : T; + bool has([Type? type]) { + var t2 = T; + if (type != null) { + t2 = type; + } else if (T == dynamic && type == null) { + return false; + } + Container? search = this; while (search != null) { - if (search._singletons.containsKey(t)) { + if (search._singletons.containsKey(t2)) { return true; - } else if (search._factories.containsKey(t)) { + } else if (search._factories.containsKey(t2)) { return true; } else { search = search._parent; @@ -59,27 +64,31 @@ class Container { /// /// It is similar to [make], but resolves an injection of either /// `Future` or `T`. - Future? makeAsync([Type? type]) { - type ??= T; + Future makeAsync([Type? type]) { + var t2 = T; + if (type != null) { + t2 = type; + } + Type? futureType; //.Future.value(null).runtimeType; if (T == dynamic) { try { - futureType = reflector.reflectFutureOf(type).reflectedType; + futureType = reflector.reflectFutureOf(t2).reflectedType; } on UnsupportedError { // Ignore this. } } - if (has(type)) { - return Future.value(make(type)); + if (has(t2)) { + return Future.value(make(t2)); } else if (has>()) { return make>(); } else if (futureType != null) { return make(futureType); } else { throw ReflectionException( - 'No injection for Future<$type> or $type was found.'); + 'No injection for Future<$t2> or $t2 was found.'); } } @@ -87,24 +96,27 @@ class Container { /// /// In contexts where a static generic type cannot be used, use /// the [type] argument, instead of [T]. - T? make([Type? type]) { - type ??= T; + T make([Type? type]) { + var t2 = T; + if (type != null) { + t2 = type; + } Container? search = this; while (search != null) { - if (search._singletons.containsKey(type)) { + if (search._singletons.containsKey(t2)) { // Find a singleton, if any. - return search._singletons[type] as T?; - } else if (search._factories.containsKey(type)) { + return search._singletons[t2] as T; + } else if (search._factories.containsKey(t2)) { // Find a factory, if any. - return search._factories[type]!(this) as T?; + return search._factories[t2]!(this) as T; } else { search = search._parent; } } - var reflectedType = reflector.reflectType(type); + var reflectedType = reflector.reflectType(t2); var positional = []; var named = {}; @@ -131,10 +143,10 @@ class Container { return reflectedType.newInstance( isDefault(constructor.name) ? '' : constructor.name, positional, - named, []).reflectee as T?; + named, []).reflectee as T; } else { throw ReflectionException( - '$type is not a class, and therefore cannot be instantiated.'); + '$t2 is not a class, and therefore cannot be instantiated.'); } } @@ -161,13 +173,16 @@ class Container { /// Returns [f]. T Function(Container) registerFactory(T Function(Container) f, {Type? as}) { - as ??= T; - - if (_factories.containsKey(as)) { - throw StateError('This container already has a factory for $as.'); + Type t2 = T; + if (as != null) { + t2 = as; } - _factories[as] = f; + if (_factories.containsKey(t2)) { + throw StateError('This container already has a factory for $t2.'); + } + + _factories[t2] = f; return f; } @@ -176,14 +191,19 @@ class Container { /// /// Returns [object]. T registerSingleton(T object, {Type? as}) { - as ??= T == dynamic ? as : T; + Type t2 = T; + if (as != null) { + t2 = as; + } else if (T == dynamic) { + t2 = as ?? object.runtimeType; + } + //as ??= T == dynamic ? as : T; - if (_singletons.containsKey(as ?? object.runtimeType)) { - throw StateError( - 'This container already has a singleton for ${as ?? object.runtimeType}.'); + if (_singletons.containsKey(t2)) { + throw StateError('This container already has a singleton for $t2.'); } - _singletons[as ?? object.runtimeType] = object; + _singletons[t2] = object; return object; } @@ -193,9 +213,9 @@ class Container { /// /// [findByName] is best reserved for internal logic that end users of code should /// not see. - T? findByName(String name) { + T findByName(String name) { if (_namedSingletons.containsKey(name)) { - return _namedSingletons[name] as T?; + return _namedSingletons[name] as T; } else if (_parent != null) { return _parent!.findByName(name); } else { diff --git a/packages/container/angel_container/pubspec.yaml b/packages/container/angel_container/pubspec.yaml index 9ab7ffa2..0cbd658b 100644 --- a/packages/container/angel_container/pubspec.yaml +++ b/packages/container/angel_container/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_container version: 3.1.1 -description: A hierarchical DI container, and pluggable backends for reflection. +description: Angel3 hierarchical DI container, and pluggable backends for reflection. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container environment: diff --git a/packages/container/angel_container/test/common.dart b/packages/container/angel_container/test/common.dart index 0afa75f5..8bbe8169 100644 --- a/packages/container/angel_container/test/common.dart +++ b/packages/container/angel_container/test/common.dart @@ -67,7 +67,7 @@ void testReflector(Reflector reflector) { }); test('constructor injects singleton', () { - var lower = container.make()!; + var lower = container.make(); expect(lower.lowercaseName, blaziken.name.toLowerCase()); }); diff --git a/packages/container/angel_container/test/has_test.dart b/packages/container/angel_container/test/has_test.dart index c0d726a9..c677a045 100644 --- a/packages/container/angel_container/test/has_test.dart +++ b/packages/container/angel_container/test/has_test.dart @@ -24,7 +24,8 @@ void main() { }); test('has on singleton', () { - expect(container.has(), true); + var result = container.has(); + expect(result, true); }); test('has on factory', () { diff --git a/packages/container/angel_container/test/named_test.dart b/packages/container/angel_container/test/named_test.dart index a80d388b..e7626e86 100644 --- a/packages/container/angel_container/test/named_test.dart +++ b/packages/container/angel_container/test/named_test.dart @@ -10,7 +10,7 @@ void main() { }); test('fetch by name', () { - expect(container.findByName('foo')!.bar, 'baz'); + expect(container.findByName('foo').bar, 'baz'); }); test('cannot redefine', () { diff --git a/packages/container/angel_container_generator/CHANGELOG.md b/packages/container/angel_container_generator/CHANGELOG.md index b593cd33..d46070a6 100644 --- a/packages/container/angel_container_generator/CHANGELOG.md +++ b/packages/container/angel_container_generator/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.0.1 + +* Updated `package:angel3_container` + ## 3.0.0 * Fixed NNBD issues diff --git a/packages/container/angel_container_generator/example/main.dart b/packages/container/angel_container_generator/example/main.dart index 1107da51..7d3b6d95 100644 --- a/packages/container/angel_container_generator/example/main.dart +++ b/packages/container/angel_container_generator/example/main.dart @@ -18,7 +18,7 @@ Future main() async { // Register a factory that creates a truck. container.registerFactory((container) { - return _TruckImpl(container.make()!); + return _TruckImpl(container.make()); }); // Use `make` to create an instance. @@ -29,16 +29,16 @@ Future main() async { print(await container.makeAsync()); // Asynchronous resolution also works for plain objects. - await container.makeAsync()?.then((t) => t.drive()); + await container.makeAsync().then((t) => t.drive()); // Register a named singleton. container.registerNamedSingleton('the_truck', truck); // Should print: 'Vroom! I have 40 horsepower in my engine.' - truck?.drive(); + truck.drive(); // Should print the same. - container.findByName('the_truck')?.drive(); + container.findByName('the_truck').drive(); // We can make a child container with its own factory. var childContainer = container.createChild(); @@ -48,10 +48,10 @@ Future main() async { }); // Make a truck with 5666 HP. - childContainer.make()?.drive(); + childContainer.make().drive(); // However, calling `make` will return the Engine singleton we created above. - print(childContainer.make()?.horsePower); + print(childContainer.make().horsePower); } abstract class Truck { diff --git a/packages/container/angel_container_generator/pubspec.yaml b/packages/container/angel_container_generator/pubspec.yaml index a1a24664..1b8e3491 100644 --- a/packages/container/angel_container_generator/pubspec.yaml +++ b/packages/container/angel_container_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_container_generator -version: 3.0.0 +version: 3.0.1 description: Codegen support for using pkg:reflectable with pkg:angel3_container. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/container/angel_container_generator @@ -13,6 +13,6 @@ dev_dependencies: build_test: ^2.1.3 test: ^1.17.5 lints: ^1.0.1 -dependency_overrides: +dependency_overrides: angel3_container: - path: ../angel_container \ No newline at end of file + path: ../container/angel_container diff --git a/packages/container/angel_container_generator/test/reflector_test.dart b/packages/container/angel_container_generator/test/reflector_test.dart index a4bf55e0..f8f728c3 100644 --- a/packages/container/angel_container_generator/test/reflector_test.dart +++ b/packages/container/angel_container_generator/test/reflector_test.dart @@ -27,7 +27,7 @@ void main() { }); test('inject constructor parameters', () { - var album = container.make()!; + var album = container.make(); print(album.title); expect(album.title, 'flowers by stevie wonder'); }); @@ -93,7 +93,7 @@ void testReflector(Reflector reflector) { }); test('constructor injects singleton', () { - var lower = container.make()!; + var lower = container.make(); expect(lower.lowercaseName, blaziken.name.toLowerCase()); }); diff --git a/packages/framework/CHANGELOG.md b/packages/framework/CHANGELOG.md index 314bd648..628f1781 100644 --- a/packages/framework/CHANGELOG.md +++ b/packages/framework/CHANGELOG.md @@ -1,9 +1,13 @@ # Change Log +## 4.2.1 + +* Updated `package:angel3_container` + ## 4.2.0 -* Updated to use `package:belatuk_combinator` -* Updated to use `package:belatuk_merge_map` +* Updated to `package:belatuk_combinator` +* Updated to `package:belatuk_merge_map` * Updated linter to `package:lints` ## 4.1.3 diff --git a/packages/framework/lib/src/core/driver.dart b/packages/framework/lib/src/core/driver.dart index ba335f20..3239f086 100644 --- a/packages/framework/lib/src/core/driver.dart +++ b/packages/framework/lib/src/core/driver.dart @@ -292,13 +292,14 @@ abstract class Driver< {bool ignoreFinalizers = false}) { if (req == null || res == null) { try { - app.logger?.severe(null, e, st); + app.logger?.severe('500 Internal Server Error', e, st); setStatusCode(response, 500); writeStringToResponse(response, '500 Internal Server Error'); closeResponse(response); - } finally { - return Future.value(); + } catch (e) { + app.logger?.severe('500 Internal Server Error', e); } + return Future.value(); } Future handleError; @@ -327,7 +328,7 @@ abstract class Driver< req.container!.has()) { var sw = req.container!.make(); app.logger?.info( - "${res.statusCode} ${req.method} ${req.uri} (${sw?.elapsedMilliseconds ?? 'unknown'} ms)"); + "${res.statusCode} ${req.method} ${req.uri} (${sw.elapsedMilliseconds} ms)"); } return req.close(); } diff --git a/packages/framework/lib/src/core/response_context.dart b/packages/framework/lib/src/core/response_context.dart index 04c4f314..87911023 100644 --- a/packages/framework/lib/src/core/response_context.dart +++ b/packages/framework/lib/src/core/response_context.dart @@ -307,7 +307,9 @@ abstract class ResponseContext /// Serializes data to the response. Future serialize(value, {MediaType? contentType}) async { - if (!isOpen) throw closed(); + if (!isOpen) { + throw closed(); + } this.contentType = contentType ?? MediaType('application', 'json'); var text = await serializer(value); if (text.isEmpty) return true; @@ -320,7 +322,9 @@ abstract class ResponseContext /// /// `HEAD` responses will not actually write data. Future streamFile(File file) async { - if (!isOpen) throw closed(); + if (!isOpen) { + throw closed(); + } var mimeType = app!.mimeTypeResolver.lookup(file.path); contentLength = await file.length(); contentType = mimeType == null diff --git a/packages/framework/lib/src/core/server.dart b/packages/framework/lib/src/core/server.dart index b6ac2872..e04cf2c8 100644 --- a/packages/framework/lib/src/core/server.dart +++ b/packages/framework/lib/src/core/server.dart @@ -288,7 +288,12 @@ class Angel extends Routable { dynamic findProperty(key) { if (configuration.containsKey(key)) return configuration[key]; - return parent != null ? parent?.findProperty(key) : null; + //return parent != null ? parent?.findProperty(key) : null; + if (parent != null) { + return parent?.findProperty(key); + } + + return null; } /// Runs several optimizations, *if* [angelEnv.isProduction] is `true`. @@ -345,7 +350,7 @@ class Angel extends Routable { /// /// If you are on `Dart >=2.0.0`, simply call `mountController()`. Future mountController([Type? type]) { - var controller = container!.make(type)!; + var controller = container!.make(type); return configure(controller.configureServer).then((_) => controller); } diff --git a/packages/framework/pubspec.yaml b/packages/framework/pubspec.yaml index f9bb38ce..e689f217 100644 --- a/packages/framework/pubspec.yaml +++ b/packages/framework/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_framework -version: 4.2.0 +version: 4.2.1 description: A high-powered HTTP server extensible framework with dependency injection, routing and much more. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework @@ -35,6 +35,6 @@ dev_dependencies: io: ^1.0.0 test: ^1.17.5 lints: ^1.0.0 -#dependency_overrides: -# angel3_container: -# path: ../container/angel_container +dependency_overrides: + angel3_container: + path: ../container/angel_container diff --git a/packages/framework/test/di_test.dart b/packages/framework/test/di_test.dart index 2ef29929..a8c511f4 100644 --- a/packages/framework/test/di_test.dart +++ b/packages/framework/test/di_test.dart @@ -27,7 +27,7 @@ void main() { // Inject some todos app.container!.registerSingleton(Todo(text: TEXT, over: OVER)); app.container!.registerFactory>((container) async { - var req = container.make()!; + var req = container.make(); var text = await utf8.decoder.bind(req.body!).join(); return Foo(text); }); diff --git a/packages/production/pubspec.yaml b/packages/production/pubspec.yaml index 4f436aa8..7248068b 100644 --- a/packages/production/pubspec.yaml +++ b/packages/production/pubspec.yaml @@ -14,6 +14,3 @@ dependencies: logging: ^1.0.1 dev_dependencies: lints: ^1.0.1 -#dependency_overrides: -# angel3_container: -# path: ../container/angel_container diff --git a/packages/shelf/pubspec.yaml b/packages/shelf/pubspec.yaml index 8bb7b810..c6419fc7 100644 --- a/packages/shelf/pubspec.yaml +++ b/packages/shelf/pubspec.yaml @@ -21,6 +21,3 @@ dev_dependencies: shelf_static: ^1.0.0 test: ^1.17.5 lints: ^1.0.0 -#dependency_overrides: -# angel3_container: -# path: ../container/angel_container diff --git a/packages/test/pubspec.yaml b/packages/test/pubspec.yaml index a878b8e8..d4c14424 100644 --- a/packages/test/pubspec.yaml +++ b/packages/test/pubspec.yaml @@ -19,7 +19,4 @@ dependencies: dev_dependencies: test: ^1.17.5 lints: ^1.0.0 -#dependency_overrides: -# angel3_websocket: -# path: ../websocket - + \ No newline at end of file diff --git a/packages/websocket/CHANGELOG.md b/packages/websocket/CHANGELOG.md index da658cf7..8e1a2c7e 100644 --- a/packages/websocket/CHANGELOG.md +++ b/packages/websocket/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.1.2 + +* Updated `package:angel3_container` + ## 4.1.1 * Fixed issue with type casting @@ -7,7 +11,7 @@ ## 4.1.0 -* Updated to use `package:belatuk_merge_map` +* Updated `package:belatuk_merge_map` * Updated linter to `package:lints` ## 4.0.1 diff --git a/packages/websocket/lib/server.dart b/packages/websocket/lib/server.dart index 3b9f6123..fd293cba 100644 --- a/packages/websocket/lib/server.dart +++ b/packages/websocket/lib/server.dart @@ -275,7 +275,7 @@ class AngelWebSocket { action.params?['query'] is Map && action.params?['query']['jwt'] is String) { try { - var auth = socket.request.container!.make()!; + var auth = socket.request.container!.make(); var jwt = action.params!['query']['jwt'] as String; AuthToken token; diff --git a/packages/websocket/pubspec.yaml b/packages/websocket/pubspec.yaml index 1cc9d375..c80a3723 100644 --- a/packages/websocket/pubspec.yaml +++ b/packages/websocket/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_websocket -version: 4.1.1 +version: 4.1.2 description: This library provides WebSockets support for Angel3 framework. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/websocket @@ -22,7 +22,11 @@ dev_dependencies: angel3_model: ^3.1.0 test: ^1.17.5 lints: ^1.0.0 -#dependency_overrides: -# angel3_auth: -# path: ../auth +dependency_overrides: + angel3_container: + path: ../container/angel_container + angel3_auth: + path: ../auth + angel3_framework: + path: ../framework \ No newline at end of file