diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..e69de29b diff --git a/.gitignore b/.gitignore index ea89ccf0..e67c11e2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,7 @@ doc/api/ # Don't commit pubspec lock file # (Library packages only! Remove pattern if developing an application package) pubspec.lock -.idea \ No newline at end of file +.idea + +lib/angel_client.js +*.sum \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..82e61f78 --- /dev/null +++ b/.npmignore @@ -0,0 +1,79 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml + +# Sensitive or high-churn files: +.idea/dataSources/ +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# Gradle: +.idea/gradle.xml +.idea/libraries + +# Mongo Explorer plugin: +.idea/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties +### Dart template +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub + +# SDK 1.20 and later (no longer creates packages directories) +.packages +.pub/ +build/ + +# Older SDK versions +# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) +.project +.buildlog +**/packages/ + + +# Files created by dart2js +# (Most Dart developers will use pub build to compile Dart, use/modify these +# rules if you intend to use dart2js directly +# Convention is to use extension '.dart.js' for Dart compiled to Javascript to +# differentiate from explicit Javascript files) +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# Don't commit pubspec lock file +# (Library packages only! Remove pattern if developing an application package) +pubspec.lock + diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..1325f758 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +analyzer: + strong-mode: true + exclude: + - test/io_test.dart \ No newline at end of file diff --git a/lib/angel_client.dart b/lib/angel_client.dart index 8ad4eb6f..d56816b3 100644 --- a/lib/angel_client.dart +++ b/lib/angel_client.dart @@ -29,7 +29,7 @@ abstract class Angel { await configurer(this); } - Service service(Pattern path, {Type type}); + Service service(String path, {Type type}); Future delete(String url, {Map headers}); diff --git a/lib/base_angel_client.dart b/lib/base_angel_client.dart index 2b2426f2..191df0bd 100644 --- a/lib/base_angel_client.dart +++ b/lib/base_angel_client.dart @@ -7,16 +7,15 @@ import 'package:http/src/base_request.dart' as http; import 'package:http/src/request.dart' as http; import 'package:http/src/response.dart' as http; import 'package:http/src/streamed_response.dart' as http; -import 'package:merge_map/merge_map.dart'; import 'angel_client.dart'; import 'auth_types.dart' as auth_types; final RegExp straySlashes = new RegExp(r"(^/)|(/+$)"); const Map _readHeaders = const {'Accept': 'application/json'}; -final Map _writeHeaders = mergeMap([ - _readHeaders, - const {'Content-Type': 'application/json'} -]); +const Map _writeHeaders = const { + 'Accept': 'application/json', + 'Content-Type': 'application/json' +}; _buildQuery(Map params) { if (params == null || params.isEmpty) return ""; @@ -66,11 +65,11 @@ abstract class BaseAngelClient extends Angel { String reviveEndpoint: '/auth/token'}) async { if (type == null) { final url = '$basePath$reviveEndpoint'; - final response = await client.post(url, - headers: mergeMap([ - _writeHeaders, - {'Authorization': 'Bearer ${credentials['token']}'} - ])); + final response = await client.post(url, headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ${credentials['token']}' + }); try { if (response.statusCode != 200) { @@ -130,7 +129,7 @@ abstract class BaseAngelClient extends Angel { @override Service service(String path, {Type type}) { - String uri = path.replaceAll(straySlashes, ""); + String uri = path.toString().replaceAll(straySlashes, ""); return new BaseAngelService(client, this, '$basePath/$uri'); } diff --git a/package.json b/package.json new file mode 100644 index 00000000..1bd640b7 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "angel_client", + "version": "1.0.0-dev", + "description": "Client library for the Angel framework.", + "main": "lib/angel_client.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/angel-dart/angel_client.git" + }, + "keywords": [ + "angel", + "angel_client" + ], + "author": "Tobe O ", + "license": "MIT", + "bugs": { + "url": "https://github.com/angel-dart/angel_client/issues" + }, + "homepage": "https://github.com/angel-dart/angel_client#readme" +} diff --git a/test/shared.dart b/test/shared.dart index 4a5e11a0..59031362 100644 --- a/test/shared.dart +++ b/test/shared.dart @@ -1,7 +1,6 @@ import "package:angel_framework/src/defs.dart"; class Postcard extends MemoryModel { - int id; String location; String message;