Skip to content

Commit

Permalink
Prepare for 3.0.0-beta.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed May 2, 2016
1 parent d6203f1 commit daa1c87
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
##### 3.0.0-beta.5 - 02 May 2016

###### Bug fixes
- Fixed typos in the code for `addAction` and `addActions`

##### 3.0.0-beta.4 - 01 May 2016

###### Other
Expand Down
2 changes: 1 addition & 1 deletion fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-data-fetch",
"description": "HTTP adapter for js-data that uses the fetch API.",
"version": "3.0.0-beta.4",
"version": "3.0.0-beta.5",
"homepage": "https://github.com/js-data/js-data-http",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-data-http-node",
"description": "Node.js HTTP adapter for js-data.",
"version": "3.0.0-beta.4",
"version": "3.0.0-beta.5",
"homepage": "https://github.com/js-data/js-data-http",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-data-http",
"description": "HTTP (XHR) adapter for js-data in the browser.",
"version": "3.0.0-beta.4",
"version": "3.0.0-beta.5",
"homepage": "https://github.com/js-data/js-data-http",
"repository": {
"type": "git",
Expand Down Expand Up @@ -85,7 +85,7 @@
"karma": "0.13.22",
"karma-browserstack-launcher": "0.1.11",
"karma-chai": "0.1.0",
"karma-mocha": "0.2.2",
"karma-mocha": "1.0.1",
"karma-phantomjs-launcher": "1.0.0",
"karma-sinon": "1.0.4",
"phantomjs-prebuilt": "2.1.7",
Expand Down
97 changes: 79 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,34 @@ utils.addHiddenPropsToTarget(HttpAdapter.prototype, {
/**
* Add an Http actions to a mapper.
*
* @example
* // CommonJS
* var JSData = require('js-data')
* // It is recommended to use DataStore in the browser
* var DataStore = JSData.DataStore
*
* var JSDataHttp = require('js-data-http')
* var HttpAdapter = JSDataHttp.HttpAdapter
* var addAction = JSDataHttp.addAction
*
* var adapter = new HttpAdapter()
* var store = new DataStore()
*
* store.registerAdapter('http', adapter, { default: true })
* store.defineMapper('school')
*
* // GET /reports/schools/:school_id/teachers
* addAction('getTeacherReports', {
* basePath: 'reports/schools',
* pathname: 'teachers',
* method: 'GET'
* })(store.getMapper('school'))
*
* // /reports/schools/1234/teachers
* store.getMapper('school').getTeacherReports(1234).then(function (response) {
* // ...
* })
*
* @name module:js-data-http.addAction
* @method
* @param {string} name Name of the new action.
Expand Down Expand Up @@ -1152,7 +1180,7 @@ exports.addAction = function addAction (name, opts) {
}
config.method = config.method || 'GET'
config.mapper = self.name
utils.deepMixIn(config)(_opts)
utils.deepMixIn(config, _opts)
return utils.resolve(config)
.then(_opts.request || opts.request)
.then(function (config) { return adapter.HTTP(config) })
Expand All @@ -1172,6 +1200,36 @@ exports.addAction = function addAction (name, opts) {
* Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for
* action configuration options.
*
* @example
* // CommonJS
* var JSData = require('js-data')
* // It is recommended to use DataStore in the browser
* var DataStore = JSData.DataStore
*
* var JSDataHttp = require('js-data-http')
* var HttpAdapter = JSDataHttp.HttpAdapter
* var addActions = JSDataHttp.addActions
*
* var adapter = new HttpAdapter()
* var store = new DataStore()
*
* store.registerAdapter('http', adapter, { default: true })
* store.defineMapper('school')
*
* addActions({
* // GET /reports/schools/:school_id/teachers
* getTeacherReports: {
* basePath: 'reports/schools',
* pathname: 'teachers',
* method: 'GET'
* }
* })(store.getMapper('school'))
*
* // /reports/schools/1234/teachers
* store.getMapper('school').getTeacherReports(1234).then(function (response) {
* // ...
* })
*
* @name module:js-data-http.addActions
* @method
* @param {Object.<string, Object>} opts Object where the key is an action name
Expand All @@ -1182,7 +1240,7 @@ exports.addAction = function addAction (name, opts) {
exports.addActions = function addActions (opts) {
opts || (opts = {})
return function (mapper) {
utils.forOwn(mapper, function (value, key) {
utils.forOwn(opts, function (value, key) {
exports.addAction(key, value)(mapper)
})
return mapper
Expand Down Expand Up @@ -1211,22 +1269,25 @@ exports.version = '<%= version %>'
* of `js-data-http` that does not bundle `axios` is registered in NPM and Bower
* as `js-data-fetch`.
*
* __Script tag__:
* ```javascript
* window.HttpAdapter
* ```
* __CommonJS__:
* ```javascript
* var HttpAdapter = require('js-data-http')
* ```
* __ES6 Modules__:
* ```javascript
* import HttpAdapter from 'js-data-http'
* ```
* __AMD__:
* ```javascript
* define('myApp', ['js-data-http'], function (HttpAdapter) { ... })
* ```
* @example <caption>Script tag</caption>
* var HttpAdapter = window.JSDataHttp.HttpAdapter
* var adapter = new HttpAdapter()
*
* @example <caption>CommonJS</caption>
* var HttpAdapter = require('js-data-Http').HttpAdapter
* var adapter = new HttpAdapter()
*
* @example <caption>ES2015 Modules</caption>
* import {HttpAdapter} from 'js-data-Http'
* const adapter = new HttpAdapter()
*
* @example <caption>AMD</caption>
* define('myApp', ['js-data-Http'], function (JSDataHttp) {
* var HttpAdapter = JSDataHttp.HttpAdapter
* var adapter = new HttpAdapter()
*
* // ...
* })
*
* @module js-data-http
*/
Expand Down

0 comments on commit daa1c87

Please sign in to comment.