Nearly
This commit is contained in:
parent
269b0483db
commit
ec67091b10
8 changed files with 124 additions and 14 deletions
0
.babelrc
Normal file
0
.babelrc
Normal file
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -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
|
||||
.idea
|
||||
|
||||
lib/angel_client.js
|
||||
*.sum
|
79
.npmignore
Normal file
79
.npmignore
Normal file
|
@ -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
|
||||
|
4
analysis_options.yaml
Normal file
4
analysis_options.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
analyzer:
|
||||
strong-mode: true
|
||||
exclude:
|
||||
- test/io_test.dart
|
|
@ -29,7 +29,7 @@ abstract class Angel {
|
|||
await configurer(this);
|
||||
}
|
||||
|
||||
Service service<T>(Pattern path, {Type type});
|
||||
Service service<T>(String path, {Type type});
|
||||
|
||||
Future<http.Response> delete(String url,
|
||||
{Map<String, String> headers});
|
||||
|
|
|
@ -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<String, String> _readHeaders = const {'Accept': 'application/json'};
|
||||
final Map<String, String> _writeHeaders = mergeMap([
|
||||
_readHeaders,
|
||||
const {'Content-Type': 'application/json'}
|
||||
]);
|
||||
const Map<String, String> _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<T>(String path, {Type type}) {
|
||||
String uri = path.replaceAll(straySlashes, "");
|
||||
String uri = path.toString().replaceAll(straySlashes, "");
|
||||
return new BaseAngelService(client, this, '$basePath/$uri');
|
||||
}
|
||||
|
||||
|
|
26
package.json
Normal file
26
package.json
Normal file
|
@ -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 <thosakwe@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/angel-dart/angel_client/issues"
|
||||
},
|
||||
"homepage": "https://github.com/angel-dart/angel_client#readme"
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import "package:angel_framework/src/defs.dart";
|
||||
|
||||
class Postcard extends MemoryModel {
|
||||
int id;
|
||||
String location;
|
||||
String message;
|
||||
|
||||
|
|
Loading…
Reference in a new issue