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

Commit 7c2cf9b

Browse files
author
Tomasz Kostuch
authored
Merge pull request #475 from DivanteLtd/hotfix/v1.12.1
Hotfix/v1.12.1
2 parents 97b183c + 864e36a commit 7c2cf9b

File tree

9 files changed

+51
-30
lines changed

9 files changed

+51
-30
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8+
## [1.12.1] - 2020.06.22
9+
10+
### Added
11+
12+
- Add request_cache to ES url - @gibkigonzo (#387)
13+
14+
### Fixed
15+
16+
- Add error status code as number in `apiError` - @gibkigonzo (#442)
17+
- Get proper tax calculation for multistore - @didkan (#464)
18+
- Create only one ES client instance per app - @gibkigonzo (#393)
19+
820
## [1.12.0] - 2020.06.01
921

1022
### Added

config/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"review"
4141
],
4242
"apiVersion": "5.6",
43-
43+
"cacheRequest": false,
4444
"searchScoring": {
4545
"attributes": {
4646
"attribute_code": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-storefront-api",
3-
"version": "1.12.0",
3+
"version": "1.12.1",
44
"private": true,
55
"description": "vue-storefront API and data services",
66
"main": "dist",

src/api/catalog.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default ({config, db}) => async function (req, res, body) {
4242
let groupId = null
4343

4444
// Request method handling: exit if not GET or POST
45-
// Other metods - like PUT, DELETE etc. should be available only for authorized users or not available at all)
45+
// Other methods - like PUT, DELETE etc. should be available only for authorized users or not available at all)
4646
if (!(req.method === 'GET' || req.method === 'POST' || req.method === 'OPTIONS')) {
4747
throw new Error('ERROR: ' + req.method + ' request method is not supported.')
4848
}
@@ -118,6 +118,7 @@ export default ({config, db}) => async function (req, res, body) {
118118
auth: auth
119119
}, async (_err, _res, _resBody) => { // TODO: add caching layer to speed up SSR? How to invalidate products (checksum on the response BEFORE processing it)
120120
if (_err || _resBody.error) {
121+
console.error(_err || _resBody.error)
121122
apiError(res, _err || _resBody.error)
122123
return
123124
}

src/lib/elastic.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ function adjustBackendProxyUrl (req, indexName, entityType, config) {
4949
delete parsedQuery.request
5050
delete parsedQuery.request_format
5151
delete parsedQuery.response_format
52+
if (config.elasticsearch.cacheRequest) {
53+
parsedQuery.request_cache = !!config.elasticsearch.cacheRequest
54+
}
55+
5256
url = config.elasticsearch.host + ':' + config.elasticsearch.port + '/' + adjustIndexName(indexName, entityType, config) + '/_search?' + queryString.stringify(parsedQuery)
5357
}
5458
if (!url.startsWith('http')) {
@@ -66,13 +70,14 @@ function adjustQuery (esQuery, entityType, config) {
6670
}
6771

6872
function getHits (result) {
69-
if (result.body) { // differences between ES5 andd ES7
73+
if (result.body) { // differences between ES5 and ES7
7074
return result.body.hits.hits
7175
} else {
7276
return result.hits.hits
7377
}
7478
}
7579

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

86-
return new es.Client({ node, auth, apiVersion, requestTimeout })
91+
if (!esClient) {
92+
esClient = new es.Client({ node, auth, apiVersion, requestTimeout })
93+
}
94+
95+
return esClient
8796
}
8897

8998
function putAlias (db, originalName, aliasName, next) {

src/lib/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ export function apiStatus (res, result = 'OK', code = 200, meta = null) {
8686
* @return {json} [result='OK'] Text message or result information object
8787
*/
8888
export function apiError (res, error) {
89-
let errorCode = error.code || error.status || 500;
89+
let errorCode = error.code || error.status;
9090
let errorMessage = error.errorMessage || error;
9191
if (error instanceof Error) {
9292
// Class 'Error' is not serializable with JSON.stringify, extract data explicitly.
9393
errorCode = error.code || errorCode;
9494
errorMessage = error.message;
9595
}
96-
return apiStatus(res, errorMessage, errorCode);
96+
return apiStatus(res, errorMessage, Number(errorCode) || 500);
9797
}
9898

9999
export function encryptToken (textToken, secret) {

src/platform/magento1/tax.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class TaxProxy extends AbstractTaxProxy {
3939
taxCountry = this._config.tax.defaultCountry
4040
}
4141
}
42-
if (sourcePriceInclTax === null) {
42+
if (sourcePriceInclTax == null) {
4343
sourcePriceInclTax = this._config.tax.sourcePriceIncludesTax
4444
}
45-
if (finalPriceInclTax === null) {
45+
if (finalPriceInclTax == null) {
4646
finalPriceInclTax = this._config.tax.finalPriceIncludesTax
4747
}
4848
this._deprecatedPriceFieldsSupport = this._config.tax.deprecatedPriceFieldsSupport

src/platform/magento2/tax.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class TaxProxy extends AbstractTaxProxy {
3838
taxCountry = this._config.tax.defaultCountry
3939
}
4040
}
41-
if (sourcePriceInclTax === null) {
41+
if (sourcePriceInclTax == null) {
4242
sourcePriceInclTax = this._config.tax.sourcePriceIncludesTax
4343
}
44-
if (finalPriceInclTax === null) {
44+
if (finalPriceInclTax == null) {
4545
finalPriceInclTax = this._config.tax.finalPriceIncludesTax
4646
}
4747
this._deprecatedPriceFieldsSupport = this._config.tax.deprecatedPriceFieldsSupport

yarn.lock

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,12 +1520,12 @@ [email protected]:
15201520
version "2.13.0"
15211521
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
15221522

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

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

@@ -3004,12 +3004,14 @@ gtoken@^3.0.0:
30043004
mime "^2.2.0"
30053005

30063006
handlebars@^4.1.2:
3007-
version "4.1.2"
3008-
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67"
3007+
version "4.7.6"
3008+
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
3009+
integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
30093010
dependencies:
3011+
minimist "^1.2.5"
30103012
neo-async "^2.6.0"
3011-
optimist "^0.6.1"
30123013
source-map "^0.6.1"
3014+
wordwrap "^1.0.0"
30133015
optionalDependencies:
30143016
uglify-js "^3.1.4"
30153017

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

4657-
minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0:
4658-
version "1.2.0"
4659-
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
4660-
4661-
minimist@^1.2.5:
4659+
minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
46624660
version "1.2.5"
46634661
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
46644662
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
@@ -4810,6 +4808,7 @@ [email protected]:
48104808
neo-async@^2.6.0:
48114809
version "2.6.1"
48124810
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
4811+
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==
48134812

48144813
nib@~1.1.2:
48154814
version "1.1.2"
@@ -5079,7 +5078,7 @@ onetime@^5.1.0:
50795078
dependencies:
50805079
mimic-fn "^2.1.0"
50815080

5082-
optimist@^0.6.1, optimist@latest:
5081+
optimist@latest:
50835082
version "0.6.1"
50845083
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
50855084
dependencies:
@@ -7150,11 +7149,11 @@ uglify-js@^2.6.1:
71507149
uglify-to-browserify "~1.0.0"
71517150

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

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

7478+
wordwrap@^1.0.0, wordwrap@~1.0.0:
7479+
version "1.0.0"
7480+
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
7481+
74797482
wordwrap@~0.0.2:
74807483
version "0.0.3"
74817484
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
74827485

7483-
wordwrap@~1.0.0:
7484-
version "1.0.0"
7485-
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
7486-
74877486
wrap-ansi@^2.0.0:
74887487
version "2.1.0"
74897488
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"

0 commit comments

Comments
 (0)