@lab009/erebus
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.reducers = exports.createAction = exports.unionOf = exports.valuesOf = exports.arrayOf = exports.Schema = undefined; | ||
exports.mergeOption = exports.reducers = exports.createRequest = exports.createAction = exports.unionOf = exports.valuesOf = exports.arrayOf = exports.Schema = undefined; | ||
@@ -15,2 +15,6 @@ var _normalizr = require('normalizr'); | ||
var _createRequest = require('./lib/createRequest'); | ||
var _createRequest2 = _interopRequireDefault(_createRequest); | ||
var _reducers = require('./reducers'); | ||
@@ -20,2 +24,4 @@ | ||
var _mergeOptions = require('./lib/mergeOptions'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -30,2 +36,4 @@ | ||
exports.createAction = _createAction2.default; | ||
exports.reducers = reducers; | ||
exports.createRequest = _createRequest2.default; | ||
exports.reducers = reducers; | ||
exports.mergeOption = _mergeOptions.mergeOption; |
@@ -11,6 +11,2 @@ 'use strict'; | ||
var _entify = require('./entify'); | ||
var _entify2 = _interopRequireDefault(_entify); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,2 +20,5 @@ | ||
if (options.type) { | ||
req.type(options.type); | ||
} | ||
if (options.headers) { | ||
@@ -40,8 +39,2 @@ req.set(options.headers); | ||
} | ||
if (options.token) { | ||
req.set({ Authorization: 'Bearer ' + options.token }); | ||
} | ||
if (options.locale) { | ||
req.set({ 'Accept-Language': options.locale }); | ||
} | ||
if (options.auth) { | ||
@@ -66,11 +59,3 @@ req.auth.apply(req, _toConsumableArray(options.auth)); | ||
var sendRequest = function sendRequest(_ref3) { | ||
var options = _ref3.options, | ||
dispatch = _ref3.dispatch; | ||
dispatch({ | ||
type: 'erebus.request', | ||
payload: options | ||
}); | ||
var sendRequest = function sendRequest(options) { | ||
var req = _superagent2.default[options.method.toLowerCase()](options.endpoint); | ||
@@ -82,19 +67,2 @@ prepareOptions({ req: req, options: options }); | ||
return res; | ||
}).then(function (res) { | ||
dispatch({ | ||
type: 'erebus.success', | ||
meta: options, | ||
payload: { | ||
raw: res.body, | ||
normalized: options.model && (0, _entify2.default)(res.body, options) | ||
} | ||
}); | ||
return res; | ||
}).catch(function (err) { | ||
dispatch({ | ||
type: 'erebus.failure', | ||
meta: options, | ||
payload: err | ||
}); | ||
throw err; | ||
}); | ||
@@ -101,0 +69,0 @@ }; |
import { Schema, arrayOf, valuesOf, unionOf } from 'normalizr'; | ||
import createAction from './lib/createAction'; | ||
import createRequest from './lib/createRequest'; | ||
import * as reducers from './reducers'; | ||
export { Schema, arrayOf, valuesOf, unionOf, createAction, reducers }; | ||
import { mergeOption } from './lib/mergeOptions'; | ||
export { Schema, arrayOf, valuesOf, unionOf, createAction, createRequest, reducers, mergeOption }; |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
import request from 'superagent'; | ||
import entify from './entify'; | ||
import superagent from 'superagent'; | ||
@@ -10,2 +9,5 @@ var prepareOptions = function prepareOptions(_ref) { | ||
if (options.type) { | ||
req.type(options.type); | ||
} | ||
if (options.headers) { | ||
@@ -26,8 +28,2 @@ req.set(options.headers); | ||
} | ||
if (options.token) { | ||
req.set({ Authorization: 'Bearer ' + options.token }); | ||
} | ||
if (options.locale) { | ||
req.set({ 'Accept-Language': options.locale }); | ||
} | ||
if (options.auth) { | ||
@@ -52,12 +48,4 @@ req.auth.apply(req, _toConsumableArray(options.auth)); | ||
var sendRequest = function sendRequest(_ref3) { | ||
var options = _ref3.options, | ||
dispatch = _ref3.dispatch; | ||
dispatch({ | ||
type: 'erebus.request', | ||
payload: options | ||
}); | ||
var req = request[options.method.toLowerCase()](options.endpoint); | ||
var sendRequest = function sendRequest(options) { | ||
var req = superagent[options.method.toLowerCase()](options.endpoint); | ||
prepareOptions({ req: req, options: options }); | ||
@@ -68,19 +56,2 @@ | ||
return res; | ||
}).then(function (res) { | ||
dispatch({ | ||
type: 'erebus.success', | ||
meta: options, | ||
payload: { | ||
raw: res.body, | ||
normalized: options.model && entify(res.body, options) | ||
} | ||
}); | ||
return res; | ||
}).catch(function (err) { | ||
dispatch({ | ||
type: 'erebus.failure', | ||
meta: options, | ||
payload: err | ||
}); | ||
throw err; | ||
}); | ||
@@ -87,0 +58,0 @@ }; |
{ | ||
"name": "@lab009/erebus", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Dead-simple API actions for Redux", | ||
"repository": "lab009/erebus", | ||
"repository": "lab009/teide", | ||
"bugs": { | ||
"url": "https://github.com/lab009/erebus/issues" | ||
"url": "https://github.com/lab009/teide/issues" | ||
}, | ||
@@ -30,5 +30,2 @@ "author": "Oleg Orlov <mail@orlovoleg.com>", | ||
"clean": "rimraf ./dist && rimraf ./es && rimraf ./coverage && rimraf ./flow-coverage", | ||
"flow": "babel-node ./tools/scripts/flow", | ||
"flow:coverage": "flow-coverage-report -i 'src/**/*.js' -t html -t json -t text", | ||
"flow:defs": "flow-typed install --overwrite", | ||
"lint": "eslint src", | ||
@@ -47,7 +44,7 @@ "preversion": "yarn run clean && yarn run build", | ||
"redux-actions": "1.2.2", | ||
"superagent": "3.5.0" | ||
"superagent": "3.5.1" | ||
}, | ||
"devDependencies": { | ||
"@lab009/babel-preset-magma": "3.1.0", | ||
"@lab009/eslint-config-magma": "3.0.4", | ||
"@lab009/babel-preset-magma": "3.1.1", | ||
"@lab009/eslint-config-magma": "3.0.5", | ||
"babel-cli": "6.24.0", | ||
@@ -57,9 +54,9 @@ "babel-core": "6.24.0", | ||
"codecov": "1.0.1", | ||
"cross-env": "3.2.3", | ||
"cross-env": "3.2.4", | ||
"enzyme": "2.7.1", | ||
"enzyme-to-json": "1.5.0", | ||
"eslint": "3.17.1", | ||
"eslint": "3.18.0", | ||
"eslint-plugin-import": "2.2.0", | ||
"eslint-plugin-jsx-a11y": "4.0.0", | ||
"eslint-plugin-react": "6.10.0", | ||
"eslint-plugin-react": "6.10.2", | ||
"jest": "19.0.2", | ||
@@ -66,0 +63,0 @@ "react": "15.4.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
29866
18
729
+ Addedsuperagent@3.5.1(transitive)
- Removedsuperagent@3.5.0(transitive)
Updatedsuperagent@3.5.1