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
|
# Don't commit pubspec lock file
|
||||||
# (Library packages only! Remove pattern if developing an application package)
|
# (Library packages only! Remove pattern if developing an application package)
|
||||||
pubspec.lock
|
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);
|
await configurer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Service service<T>(Pattern path, {Type type});
|
Service service<T>(String path, {Type type});
|
||||||
|
|
||||||
Future<http.Response> delete(String url,
|
Future<http.Response> delete(String url,
|
||||||
{Map<String, String> headers});
|
{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/request.dart' as http;
|
||||||
import 'package:http/src/response.dart' as http;
|
import 'package:http/src/response.dart' as http;
|
||||||
import 'package:http/src/streamed_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 'angel_client.dart';
|
||||||
import 'auth_types.dart' as auth_types;
|
import 'auth_types.dart' as auth_types;
|
||||||
|
|
||||||
final RegExp straySlashes = new RegExp(r"(^/)|(/+$)");
|
final RegExp straySlashes = new RegExp(r"(^/)|(/+$)");
|
||||||
const Map<String, String> _readHeaders = const {'Accept': 'application/json'};
|
const Map<String, String> _readHeaders = const {'Accept': 'application/json'};
|
||||||
final Map<String, String> _writeHeaders = mergeMap([
|
const Map<String, String> _writeHeaders = const {
|
||||||
_readHeaders,
|
'Accept': 'application/json',
|
||||||
const {'Content-Type': 'application/json'}
|
'Content-Type': 'application/json'
|
||||||
]);
|
};
|
||||||
|
|
||||||
_buildQuery(Map params) {
|
_buildQuery(Map params) {
|
||||||
if (params == null || params.isEmpty) return "";
|
if (params == null || params.isEmpty) return "";
|
||||||
|
@ -66,11 +65,11 @@ abstract class BaseAngelClient extends Angel {
|
||||||
String reviveEndpoint: '/auth/token'}) async {
|
String reviveEndpoint: '/auth/token'}) async {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
final url = '$basePath$reviveEndpoint';
|
final url = '$basePath$reviveEndpoint';
|
||||||
final response = await client.post(url,
|
final response = await client.post(url, headers: {
|
||||||
headers: mergeMap([
|
'Accept': 'application/json',
|
||||||
_writeHeaders,
|
'Content-Type': 'application/json',
|
||||||
{'Authorization': 'Bearer ${credentials['token']}'}
|
'Authorization': 'Bearer ${credentials['token']}'
|
||||||
]));
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
|
@ -130,7 +129,7 @@ abstract class BaseAngelClient extends Angel {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Service service<T>(String path, {Type type}) {
|
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');
|
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";
|
import "package:angel_framework/src/defs.dart";
|
||||||
|
|
||||||
class Postcard extends MemoryModel {
|
class Postcard extends MemoryModel {
|
||||||
int id;
|
|
||||||
String location;
|
String location;
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue