Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #153 from doktordirk/id-criteria
Browse files Browse the repository at this point in the history
use spoonx-tools, better typings, add findOne... methods
  • Loading branch information
doktordirk committed Aug 18, 2016
2 parents dca4418 + f4ea969 commit 191b06c
Show file tree
Hide file tree
Showing 29 changed files with 566 additions and 936 deletions.
6 changes: 2 additions & 4 deletions .eslintrc.json
@@ -1,6 +1,4 @@
{
"extends": "./node_modules/aurelia-tools/.eslintrc.json",
"rules": {
"no-new-func": 0
}
"extends": "./node_modules/spoonx-tools/.eslintrc.json",
"rules": {}
}
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '0.12'
- '5.7.0'
before_install:
- npm install -g jspm
- jspm config registries.github.auth U3Bvb25YOjY2NWIxYWQ2ZTM4ZjUxZGNjMzcwNDBkYzMxYjgxZGVkZjE1M2RjYjg=
Expand Down
32 changes: 22 additions & 10 deletions README.md
Expand Up @@ -135,17 +135,29 @@ export class MyClass {

## Quick Rest api overview

All methods will, when the body is passed as an object, stringify the body if the `Content-Type` is set to `application/json` or convert the body to querystring format for all other set `Content-Type`s.
All methods will:

* stringify the body, if it is an object and the `Content-Type` is set to `application/json` (the default).
* convert the body to querystring format, if the body is an object and the `Content-Type` is set to any other value.
* leave the body unchanged, if the `Content-Type` is not set or when the body is not an object.
* maintain trailing slashes of the resource parameter

All methods return on success a Promise with the server response parsed to an object if possible. On error, they reject with the server response. If possible and parseError is set true, they reject with the JSON parsed server response.

````js
endpoint
.client // the httpClient instance
.endpoint // name of the endpoint
.find(resource, criteria, options) // GET
.post(resource, body, options) { // POST
.update(resource, criteria, body, options) // PUT
.patch(resource, criteria, body, options) // PATCH
.destroy(resource, criteria, options) // DELETE
.create(resource, body, options) // POST
.request(method, path, body, options) // method
.client // the httpClient instance
.endpoint // name of the endpoint
.default // The fetch client defaults
.find(resource, criteria, options) // GET
.findOne(resource, id, criteria, options) // GET
.post(resource, body, options) { // POST
.update(resource, criteria, body, options) // PUT
.updateOne(resource, id, criteria, body, options) // PUT
.patch(resource, criteria, body, options) // PATCH
.patchOne(resource, id, criteria, body, options) // PATCH
.destroy(resource, criteria, options) // DELETE
.destroyOne(resource, id, criteria, options) // DELETE
.create(resource, body, options) // POST
.request(method, path, body, options) // method
```
1 change: 1 addition & 0 deletions bower.json
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"aurelia-dependency-injection": "^1.0.0-rc.1.0.0",
"aurelia-fetch-client": "^1.0.0-rc.1.0.0",
"aurelia-framework": "^1.0.0-rc.1.0.0",
"aurelia-path": "^1.0.0-rc.1.0.0",
"extend": "^3.0.0"
}
Expand Down
13 changes: 0 additions & 13 deletions build/args.js

This file was deleted.

65 changes: 0 additions & 65 deletions build/babel-options.js

This file was deleted.

36 changes: 0 additions & 36 deletions build/paths.js

This file was deleted.

184 changes: 0 additions & 184 deletions build/tasks/build.js

This file was deleted.

9 changes: 0 additions & 9 deletions build/tasks/clean.js

This file was deleted.

0 comments on commit 191b06c

Please sign in to comment.