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

Commit 10d7ba7

Browse files
committed
Merge branch 'bugfix/elastic-search-query-missing-source' of github.com:seSze/vue-storefront-api into bugfix/elastic-search-query-missing-source
2 parents be3aac7 + 1886644 commit 10d7ba7

File tree

7 files changed

+34
-6
lines changed

7 files changed

+34
-6
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"useRequestFilter": false,
4444
"overwriteRequestSourceParams": false,
4545
"requestParamsBlacklist": [],
46+
"cacheRequest": false,
4647
"searchScoring": {
4748
"attributes": {
4849
"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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export default ({config, db}) => async function (req, res, body) {
149149
auth: auth
150150
}, async (_err, _res, _resBody) => { // TODO: add caching layer to speed up SSR? How to invalidate products (checksum on the response BEFORE processing it)
151151
if (_err || _resBody.error) {
152+
console.error(_err || _resBody.error)
152153
apiError(res, _err || _resBody.error)
153154
return
154155
}

src/lib/elastic.js

Lines changed: 10 additions & 1 deletion
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')) {
@@ -73,6 +77,7 @@ function getHits (result) {
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) {

yarn.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ acorn@^6.0.1, acorn@^6.0.7:
667667
agent-base@^4.3.0:
668668
version "4.3.0"
669669
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
670+
integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==
670671
dependencies:
671672
es6-promisify "^5.0.0"
672673

@@ -1837,6 +1838,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.3, debug@^2.6.8, debug@^2.6.
18371838
debug@^3, debug@^3.0, debug@^3.1.0, debug@^3.2.6:
18381839
version "3.2.6"
18391840
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
1841+
integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==
18401842
dependencies:
18411843
ms "^2.1.1"
18421844

@@ -2151,10 +2153,12 @@ es-to-primitive@^1.2.0:
21512153
es6-promise@^4.0.3:
21522154
version "4.2.8"
21532155
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a"
2156+
integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==
21542157

21552158
es6-promisify@^5.0.0:
21562159
version "5.0.0"
21572160
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
2161+
integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=
21582162
dependencies:
21592163
es6-promise "^4.0.3"
21602164

@@ -3141,8 +3145,9 @@ httpreq@>=0.4.22:
31413145
resolved "https://registry.yarnpkg.com/httpreq/-/httpreq-0.4.24.tgz#4335ffd82cd969668a39465c929ac61d6393627f"
31423146

31433147
https-proxy-agent@^2.2.1:
3144-
version "2.2.2"
3145-
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz#271ea8e90f836ac9f119daccd39c19ff7dfb0793"
3148+
version "2.2.4"
3149+
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b"
3150+
integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==
31463151
dependencies:
31473152
agent-base "^4.3.0"
31483153
debug "^3.1.0"

0 commit comments

Comments
 (0)