Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #475 from DivanteLtd/hotfix/v1.12.1
Browse files Browse the repository at this point in the history
Hotfix/v1.12.1
  • Loading branch information
Tomasz Kostuch authored Jun 22, 2020
2 parents 97b183c + 864e36a commit 7c2cf9b
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 30 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.12.1] - 2020.06.22

### Added

- Add request_cache to ES url - @gibkigonzo (#387)

### Fixed

- Add error status code as number in `apiError` - @gibkigonzo (#442)
- Get proper tax calculation for multistore - @didkan (#464)
- Create only one ES client instance per app - @gibkigonzo (#393)

## [1.12.0] - 2020.06.01

### Added
Expand Down
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"review"
],
"apiVersion": "5.6",

"cacheRequest": false,
"searchScoring": {
"attributes": {
"attribute_code": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-storefront-api",
"version": "1.12.0",
"version": "1.12.1",
"private": true,
"description": "vue-storefront API and data services",
"main": "dist",
Expand Down
3 changes: 2 additions & 1 deletion src/api/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default ({config, db}) => async function (req, res, body) {
let groupId = null

// Request method handling: exit if not GET or POST
// Other metods - like PUT, DELETE etc. should be available only for authorized users or not available at all)
// Other methods - like PUT, DELETE etc. should be available only for authorized users or not available at all)
if (!(req.method === 'GET' || req.method === 'POST' || req.method === 'OPTIONS')) {
throw new Error('ERROR: ' + req.method + ' request method is not supported.')
}
Expand Down Expand Up @@ -118,6 +118,7 @@ export default ({config, db}) => async function (req, res, body) {
auth: auth
}, async (_err, _res, _resBody) => { // TODO: add caching layer to speed up SSR? How to invalidate products (checksum on the response BEFORE processing it)
if (_err || _resBody.error) {
console.error(_err || _resBody.error)
apiError(res, _err || _resBody.error)
return
}
Expand Down
13 changes: 11 additions & 2 deletions src/lib/elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function adjustBackendProxyUrl (req, indexName, entityType, config) {
delete parsedQuery.request
delete parsedQuery.request_format
delete parsedQuery.response_format
if (config.elasticsearch.cacheRequest) {
parsedQuery.request_cache = !!config.elasticsearch.cacheRequest
}

url = config.elasticsearch.host + ':' + config.elasticsearch.port + '/' + adjustIndexName(indexName, entityType, config) + '/_search?' + queryString.stringify(parsedQuery)
}
if (!url.startsWith('http')) {
Expand All @@ -66,13 +70,14 @@ function adjustQuery (esQuery, entityType, config) {
}

function getHits (result) {
if (result.body) { // differences between ES5 andd ES7
if (result.body) { // differences between ES5 and ES7
return result.body.hits.hits
} else {
return result.hits.hits
}
}

let esClient = null
function getClient (config) {
let { host, port, protocol, apiVersion, requestTimeout } = config.elasticsearch
const node = `${protocol}://${host}:${port}`
Expand All @@ -83,7 +88,11 @@ function getClient (config) {
auth = { username: user, password }
}

return new es.Client({ node, auth, apiVersion, requestTimeout })
if (!esClient) {
esClient = new es.Client({ node, auth, apiVersion, requestTimeout })
}

return esClient
}

function putAlias (db, originalName, aliasName, next) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export function apiStatus (res, result = 'OK', code = 200, meta = null) {
* @return {json} [result='OK'] Text message or result information object
*/
export function apiError (res, error) {
let errorCode = error.code || error.status || 500;
let errorCode = error.code || error.status;
let errorMessage = error.errorMessage || error;
if (error instanceof Error) {
// Class 'Error' is not serializable with JSON.stringify, extract data explicitly.
errorCode = error.code || errorCode;
errorMessage = error.message;
}
return apiStatus(res, errorMessage, errorCode);
return apiStatus(res, errorMessage, Number(errorCode) || 500);
}

export function encryptToken (textToken, secret) {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/magento1/tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class TaxProxy extends AbstractTaxProxy {
taxCountry = this._config.tax.defaultCountry
}
}
if (sourcePriceInclTax === null) {
if (sourcePriceInclTax == null) {
sourcePriceInclTax = this._config.tax.sourcePriceIncludesTax
}
if (finalPriceInclTax === null) {
if (finalPriceInclTax == null) {
finalPriceInclTax = this._config.tax.finalPriceIncludesTax
}
this._deprecatedPriceFieldsSupport = this._config.tax.deprecatedPriceFieldsSupport
Expand Down
4 changes: 2 additions & 2 deletions src/platform/magento2/tax.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class TaxProxy extends AbstractTaxProxy {
taxCountry = this._config.tax.defaultCountry
}
}
if (sourcePriceInclTax === null) {
if (sourcePriceInclTax == null) {
sourcePriceInclTax = this._config.tax.sourcePriceIncludesTax
}
if (finalPriceInclTax === null) {
if (finalPriceInclTax == null) {
finalPriceInclTax = this._config.tax.finalPriceIncludesTax
}
this._deprecatedPriceFieldsSupport = this._config.tax.deprecatedPriceFieldsSupport
Expand Down
37 changes: 18 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1520,12 +1520,12 @@ [email protected]:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"

commander@^2.18.0:
commander@^2.18.0, commander@~2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@^2.9.0, commander@~2.20.0:
commander@^2.9.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"

Expand Down Expand Up @@ -3004,12 +3004,14 @@ gtoken@^3.0.0:
mime "^2.2.0"

handlebars@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67"
version "4.7.6"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
dependencies:
minimist "^1.2.5"
neo-async "^2.6.0"
optimist "^0.6.1"
source-map "^0.6.1"
wordwrap "^1.0.0"
optionalDependencies:
uglify-js "^3.1.4"

Expand Down Expand Up @@ -4654,11 +4656,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=

minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

minimist@^1.2.5:
minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
Expand Down Expand Up @@ -4810,6 +4808,7 @@ [email protected]:
neo-async@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==

nib@~1.1.2:
version "1.1.2"
Expand Down Expand Up @@ -5079,7 +5078,7 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"

optimist@^0.6.1, optimist@latest:
optimist@latest:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
dependencies:
Expand Down Expand Up @@ -7150,11 +7149,11 @@ uglify-js@^2.6.1:
uglify-to-browserify "~1.0.0"

uglify-js@^3.1.4:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
version "3.9.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.9.4.tgz#867402377e043c1fc7b102253a22b64e5862401b"
integrity sha512-8RZBJq5smLOa7KslsNsVcSH+KOXf1uDU8yqLeNuVKwmT0T3FA0ZoXlinQfRad7SDcbZZRZE4ov+2v71EnxNyCA==
dependencies:
commander "~2.20.0"
source-map "~0.6.1"
commander "~2.20.3"

uglify-to-browserify@~1.0.0:
version "1.0.2"
Expand Down Expand Up @@ -7476,14 +7475,14 @@ [email protected]:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
integrity sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=

wordwrap@^1.0.0, wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"

wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"

wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"

wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
Expand Down

0 comments on commit 7c2cf9b

Please sign in to comment.