diff --git a/packages/client/lib/angel_client.dart b/packages/client/lib/angel_client.dart index 103fc7ce..10d2f95d 100644 --- a/packages/client/lib/angel_client.dart +++ b/packages/client/lib/angel_client.dart @@ -124,7 +124,7 @@ class AngelAuthResult { /// Attempts to deserialize a response from a [Map]. factory AngelAuthResult.fromMap(Map data) { - final result = new AngelAuthResult(); + final result = AngelAuthResult(); if (data is Map && data.containsKey('token') && data['token'] is String) result._token = data['token'].toString(); @@ -133,10 +133,10 @@ class AngelAuthResult { result.data.addAll((data['data'] as Map) ?? {}); if (result.token == null) { - throw new FormatException( + throw FormatException( 'The required "token" field was not present in the given data.'); } else if (data['data'] is! Map) { - throw new FormatException( + throw FormatException( 'The required "data" field in the given data was not a map; instead, it was ${data['data']}.'); } @@ -145,7 +145,7 @@ class AngelAuthResult { /// Attempts to deserialize a response from a [String]. factory AngelAuthResult.fromJson(String s) => - new AngelAuthResult.fromMap(json.decode(s) as Map); + AngelAuthResult.fromMap(json.decode(s) as Map); /// Converts this instance into a JSON-friendly representation. Map toJson() { @@ -200,7 +200,7 @@ abstract class Service { /// /// Handy utility for handling data in a type-safe manner. Service map(U Function(Data) encoder, Data Function(U) decoder) { - return new _MappedService(this, encoder, decoder); + return _MappedService(this, encoder, decoder); } } @@ -215,7 +215,7 @@ class _MappedService extends Service { Angel get app => inner.app; @override - Future close() => new Future.value(); + Future close() => Future.value(); @override Future create(U data, [Map params]) { @@ -281,19 +281,18 @@ class ServiceList extends DelegatingList { final Service service; - final StreamController> _onChange = - new StreamController(); + final StreamController> _onChange = StreamController(); final List _subs = []; ServiceList(this.service, {this.idField = 'id', Equality equality}) : super([]) { _equality = equality; - _equality ??= new EqualityBy((map) { + _equality ??= EqualityBy((map) { if (map is Map) return map[idField ?? 'id'] as Id; else - throw new UnsupportedError( + throw UnsupportedError( 'ServiceList only knows how to find the id from a Map object. Provide a custom `Equality` in your call to the constructor.'); }); // Index diff --git a/packages/client/lib/base_angel_client.dart b/packages/client/lib/base_angel_client.dart index efc18ca7..dc660bba 100644 --- a/packages/client/lib/base_angel_client.dart +++ b/packages/client/lib/base_angel_client.dart @@ -70,7 +70,11 @@ abstract class BaseAngelClient extends Angel { var segments = baseUrl.pathSegments .followedBy(p.split(authEndpoint)) .followedBy([type]); - var url = baseUrl.replace(path: p.joinAll(segments)); + + // TODO: convert windows path to proper url + var p1 = p.joinAll(segments).replaceAll('\\', '/'); + + var url = baseUrl.replace(path: p1); http.Response response; if (credentials != null) { diff --git a/packages/client/lib/io.dart b/packages/client/lib/io.dart index c94a4ee2..30a24901 100644 --- a/packages/client/lib/io.dart +++ b/packages/client/lib/io.dart @@ -13,13 +13,13 @@ export 'angel_client.dart'; class Rest extends BaseAngelClient { final List _services = []; - Rest(String path) : super(new http.Client() as http.BaseClient, path); + Rest(String path) : super(http.Client() as http.BaseClient, path); @override Service service(String path, {Type type, AngelDeserializer deserializer}) { var url = baseUrl.replace(path: p.join(baseUrl.path, path)); - var s = new RestService(client, this, url, type); + var s = RestService(client, this, url, type); _services.add(s); return s; } @@ -27,10 +27,11 @@ class Rest extends BaseAngelClient { @override Stream authenticateViaPopup(String url, {String eventName = 'token'}) { - throw new UnimplementedError( + throw UnimplementedError( 'Opening popup windows is not supported in the `dart:io` client.'); } + @override Future close() async { await super.close(); await Future.wait(_services.map((s) => s.close())).then((_) { @@ -48,6 +49,7 @@ class RestService extends BaseAngelService { @override Data deserialize(x) { + print(x); if (type != null) { return x.runtimeType == type ? x as Data @@ -58,7 +60,8 @@ class RestService extends BaseAngelService { } @override - makeBody(x) { + String makeBody(x) { + print(x); if (type != null) { return super.makeBody(god.serializeObject(x)); } diff --git a/packages/client/pubspec.yaml b/packages/client/pubspec.yaml index e7cb4574..74d0eb1b 100644 --- a/packages/client/pubspec.yaml +++ b/packages/client/pubspec.yaml @@ -10,7 +10,8 @@ dependencies: path: ../http_exception collection: ^1.0.0 http: ^0.12.0 - json_god: ">=2.0.0-beta <3.0.0" + json_god: ^2.0.0-beta + #dart_json_mapper: ^1.7.0 meta: ^1.0.0 path: ^1.0.0 dev_dependencies: diff --git a/packages/static/test/push_state_test.dart b/packages/static/test/push_state_test.dart index 1312407f..36e07d36 100644 --- a/packages/static/test/push_state_test.dart +++ b/packages/static/test/push_state_test.dart @@ -5,7 +5,7 @@ import 'package:file/memory.dart'; import 'package:logging/logging.dart'; import 'package:test/test.dart'; -main() { +void main() { Angel app; MemoryFileSystem fileSystem; TestClient client; @@ -48,6 +48,7 @@ main() { test('serves as fallback', () async { var response = await client.get('/nope'); + print(response); expect(response.body, 'index'); }); } diff --git a/packages/websocket/test/auth_test.dart b/packages/websocket/test/auth_test.dart index cda9c147..10436c01 100644 --- a/packages/websocket/test/auth_test.dart +++ b/packages/websocket/test/auth_test.dart @@ -36,22 +36,23 @@ void main() { await app.configure(auth.configureServer); var sock = AngelWebSocket(app); + await app.configure(sock.configureServer); app.all('/ws', sock.handleRequest); app.logger = Logger('angel_auth')..onRecord.listen(print); var server = await http.startServer(); + client = c.Rest('http://${server.address.address}:${server.port}'); + ws = c.WebSockets('ws://${server.address.address}:${server.port}/ws'); await ws.connect(); }); tearDown(() { - return Future.wait([ - http.close(), - client.close(), - ws.close(), - ]); + http.close(); + client.close(); + ws.close(); }); test('auth event fires', () async {