sptrans-promise
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -7,2 +7,6 @@ 'use strict'; | ||
var _promise = require('babel-runtime/core-js/promise'); | ||
var _promise2 = _interopRequireDefault(_promise); | ||
var _axios = require('axios'); | ||
@@ -64,3 +68,3 @@ | ||
exports.default = function (token) { | ||
return Promise.resolve(token).then(checkIfHasToken).then(fetchData).catch(handleError); | ||
return _promise2.default.resolve(token).then(checkIfHasToken).then(fetchData); | ||
}; |
@@ -7,4 +7,5 @@ 'use strict'; | ||
exports.default = { | ||
localhost: 'http://localhost:8888', | ||
endpoint: 'http://api.olhovivo.sptrans.com.br/v0', | ||
heroku: 'https://sptrans-server.herokuapp.com/sptrans', | ||
heroku: 'https://sptrans-server.herokuapp.com', | ||
auth: { | ||
@@ -11,0 +12,0 @@ route: '/login/autenticar', |
@@ -7,2 +7,14 @@ 'use strict'; | ||
var _promise = require('babel-runtime/core-js/promise'); | ||
var _promise2 = _interopRequireDefault(_promise); | ||
var _assign = require('babel-runtime/core-js/object/assign'); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty'); | ||
var _defineProperty3 = _interopRequireDefault(_defineProperty2); | ||
var _axios = require('axios'); | ||
@@ -14,6 +26,6 @@ | ||
var _helpers = require('./helpers'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var isBrowser = typeof window !== 'undefined'; | ||
@@ -61,3 +73,3 @@ | ||
return paramValue.map(function (value) { | ||
return _defineProperty({}, cur, value); | ||
return (0, _defineProperty3.default)({}, cur, value); | ||
}); | ||
@@ -70,3 +82,3 @@ } | ||
var params = requiredParams.reduce(build, {}); | ||
return Object.assign(options, { params: params }); | ||
return (0, _assign2.default)(options, { params: params }); | ||
} | ||
@@ -79,3 +91,6 @@ | ||
function handleResponse(res) { | ||
function handleResponse(res, options) { | ||
if (options.tipo === 'linhas') { | ||
return (0, _helpers.buildLinhasResponse)(res.data); | ||
} | ||
return res.data; | ||
@@ -93,4 +108,4 @@ } | ||
headers = null; | ||
url = _constants.API.heroku; | ||
Object.assign(params, { | ||
url = _constants.API.heroku + '/find'; | ||
(0, _assign2.default)(params, { | ||
auth: options.auth, | ||
@@ -112,3 +127,3 @@ route: _constants.API[options.tipo].route | ||
var promises = options.params.map(buildPromise); | ||
return Promise.all(promises).then(function (res) { | ||
return _promise2.default.all(promises).then(function (res) { | ||
return res.map(validateHttpStatus); | ||
@@ -120,7 +135,9 @@ }).then(function (res) { | ||
return buildPromise(options.params).then(validateHttpStatus).then(handleResponse); | ||
return buildPromise(options.params).then(validateHttpStatus).then(function (res) { | ||
return handleResponse(res, options); | ||
}); | ||
} | ||
exports.default = function (options) { | ||
return Promise.resolve(options).then(hasOptions).then(hasAuth).then(isAllowedType).then(hasRequiredParams).then(buildParams).then(fetchData); | ||
return _promise2.default.resolve(options).then(hasOptions).then(hasAuth).then(isAllowedType).then(hasRequiredParams).then(buildParams).then(fetchData); | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"description": "Busca informações em tempo real da frota de ônibus da SPTrans na cidade de São Paulo.", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"license": "MIT", | ||
@@ -30,2 +30,4 @@ "main": "build/server/index.js", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-polyfill": "^6.23.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
@@ -40,7 +42,15 @@ "babelify": "^7.3.0", | ||
"dependencies": { | ||
"axios": "^0.16.0" | ||
"axios": "^0.16.0", | ||
"babel-runtime": "^6.23.0" | ||
}, | ||
"ava": { | ||
"babel": { | ||
"presets": [ | ||
"es2015", | ||
"@ava/stage-4" | ||
] | ||
}, | ||
"require": [ | ||
"babel-register" | ||
"babel-register", | ||
"babel-polyfill" | ||
] | ||
@@ -47,0 +57,0 @@ }, |
@@ -76,3 +76,3 @@ <h1 align="center">SPTrans Promise</h1> | ||
const encontrarLinhas = auth => { | ||
function encontrarLinhas (auth) { | ||
sptrans.find({ | ||
@@ -88,12 +88,3 @@ auth, | ||
``` | ||
O parâmetro `termosBusca` também aceita um `array` de `strings` para buscar várias linhas ao mesmo tempo. Exemplo: | ||
``` js | ||
sptrans.find({ | ||
auth, | ||
tipo: 'linhas', | ||
termosBusca: ['Term. Lapa', 'Term. Pirituba'] | ||
}).then(console.log) | ||
``` | ||
#### Paradas | ||
@@ -100,0 +91,0 @@ O tipo `paradas` possibilita a consulta pelos pontos de parada da cidade de São Paulo. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
252080
15
595
2
14
244
2
+ Addedbabel-runtime@^6.23.0
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)