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

Commit eaf84f6

Browse files
author
tkostuch
committed
Merge remote-tracking branch 'github/master'
2 parents b841f20 + 7c2cf9b commit eaf84f6

File tree

21 files changed

+302
-88
lines changed

21 files changed

+302
-88
lines changed

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ 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.0-rc1] - UNRELEASED
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+
20+
## [1.12.0] - 2020.06.01
921

1022
### Added
1123
- Add url module - @gibkigonzo (#3942)
@@ -28,6 +40,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2840
- Add outputFormatter to response from cache - @gibkigonzo (#428)
2941
- disable showing stack for invalid requests - @gibkigonzo (#431)
3042
- Improve `_outputFormatter` on cache catalog-response to prevent exception - @cewald (#432)
43+
- use ts for compiling additional scripts - @gibkigonzo (#437)
44+
- Bugfix for wrong JSON scheme url's and hostname resolution for `magento1` platform - @cewald (#443)
45+
- check if headers has been already sent in image middleware - @gibkigonzo (#434)
46+
- Missing packages in Docker Makefile (make, python and g++) - @proxiblue (#448)
47+
- change path in ecosystem for o2m - @gibkigonzo (#434)
48+
- udpate typings for query params - @gibkigonzo (#446)
3149

3250
## [1.11.1] - 2020.03.17
3351

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": {

docker/vue-storefront-api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apk add --no-cache curl git
99
COPY package.json ./
1010
COPY yarn.lock ./
1111

12-
RUN apk add --no-cache --virtual .build-deps ca-certificates wget && \
12+
RUN apk add --no-cache --virtual .build-deps ca-certificates wget python make g++ && \
1313
yarn install --no-cache && \
1414
apk del .build-deps
1515

ecosystem.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
{
1010
"name": "o2m",
11-
"script": "./dist/worker/order_to_magento2.js",
11+
"script": "./dist/src/worker/order_to_magento2.js",
1212
"args": "start",
1313
"log_date_format": "YYYY-MM-DD HH:mm:ss",
1414
"ignore_watch": ["node_modules"]

package.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-storefront-api",
3-
"version": "1.11.1",
3+
"version": "1.12.1",
44
"private": true,
55
"description": "vue-storefront API and data services",
66
"main": "dist",
@@ -15,22 +15,22 @@
1515
"build:copy:graphql": "cpx src/**/*.graphqls dist/src",
1616
"build:copy:schema": "cpx 'src/**/*.schema*.json' dist/src",
1717
"start": "pm2 start ecosystem.json $PM2_ARGS",
18-
"db": "node scripts/db.js",
19-
"cache": "node ./scripts/cache",
20-
"mage2vs": "node scripts/mage2vs.js",
21-
"restore": "node scripts/elastic.js restore && npm run db rebuild",
18+
"db": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register scripts/db.js",
19+
"cache": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register ./scripts/cache",
20+
"mage2vs": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register scripts/mage2vs.js",
21+
"restore": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register scripts/elastic.js restore && npm run db rebuild",
2222
"restore_it": "npm run restore -- --input-file=var/catalog_it.json --output-index=vue_storefront_catalog_it && npm run db rebuild -- --indexName=vue_storefront_catalog_it",
2323
"restore_de": "npm run restore -- --input-file=var/catalog_de.json --output-index=vue_storefront_catalog_de && npm run db rebuild -- --indexName=vue_storefront_catalog_de",
2424
"restore2main": "npm run restore -- --output-index=vue_storefront_catalog",
25-
"dump": "node scripts/elastic.js dump",
25+
"dump": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register scripts/elastic.js dump",
2626
"dump_it": "npm run dump -- --input-index=vue_storefront_catalog --output-file=var/catalog_it.json",
2727
"dump_de": "npm run dump -- --input-index=vue_storefront_catalog --output-file=var/catalog_de.json",
28-
"kue": "node scripts/kue.js",
28+
"kue": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register scripts/kue.js",
2929
"kue-dashboard": "npm run kue dashboard -- --port=3050",
30-
"o2m": "node src/worker/order_to_magento2.js start",
31-
"o2m-anon": "node src/worker/order_to_magento2.js testAnon",
32-
"o2m-auth": "node src/worker/order_to_magento2.js testAuth",
33-
"o2m-dev": "nodemon -w src/worker/order_to_magento2.js --exec \"node src/worker/order_to_magento2.js\"",
30+
"o2m": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register src/worker/order_to_magento2.js start",
31+
"o2m-anon": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register src/worker/order_to_magento2.js testAnon",
32+
"o2m-auth": "cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register src/worker/order_to_magento2.js testAuth",
33+
"o2m-dev": "nodemon -w src/worker/order_to_magento2.js --exec \"cross-env TS_NODE_PROJECT=\"tsconfig-build.json\" && ts-node -r tsconfig-paths/register src/worker/order_to_magento2.js\"",
3434
"migrate": "node node_modules/migrate/bin/migrate",
3535
"prestart": "npm run -s build",
3636
"test": "eslint src",
@@ -54,10 +54,11 @@
5454
"ajv-keywords": "^3.4.0",
5555
"body-parser": "^1.18.2",
5656
"bodybuilder": "2.2.21",
57-
"commander": "^2.19.0",
57+
"commander": "^5.1.0",
5858
"compression": "^1.7.2",
5959
"config": "^1.30.0",
6060
"cors": "^2.8.4",
61+
"cross-env": "^7.0.2",
6162
"elasticdump": "^6.9.1",
6263
"email-check": "^1.1.0",
6364
"express": "^4.16.3",
@@ -89,16 +90,18 @@
8990
"resource-router-middleware": "^0.6.0",
9091
"sharp": "^0.23.4",
9192
"soap": "^0.25.0",
92-
"storefront-query-builder": "^1.0.0",
93+
"storefront-query-builder": "https://github.com/DivanteLtd/storefront-query-builder.git",
9394
"syswide-cas": "latest",
95+
"tsconfig-paths": "^3.9.0",
9496
"winston": "^2.4.2"
9597
},
9698
"devDependencies": {
9799
"@types/body-parser": "^1.17.0",
98100
"@types/config": "^0.0.34",
99-
"@types/express": "^4.16.1",
100-
"@types/jest": "^24.0.11",
101-
"@types/node": "^11.13.4",
101+
"@types/express": "^4.17.6",
102+
"@types/express-serve-static-core": "^4.17.7",
103+
"@types/jest": "^25.2.3",
104+
"@types/node": "^14.0.5",
102105
"@typescript-eslint/eslint-plugin": "^1.7.1-alpha.17",
103106
"@typescript-eslint/parser": "^1.7.1-alpha.17",
104107
"apollo-server-express": "^1.3.6",

src/api/catalog.ts

Lines changed: 7 additions & 2 deletions
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
}
@@ -51,7 +51,11 @@ export default ({config, db}) => async function (req, res, body) {
5151
let requestBody = req.body
5252
if (req.method === 'GET') {
5353
if (req.query.request) { // this is in fact optional
54-
requestBody = JSON.parse(decodeURIComponent(req.query.request))
54+
try {
55+
requestBody = JSON.parse(decodeURIComponent(req.query.request))
56+
} catch (err) {
57+
throw new Error(err)
58+
}
5559
}
5660
}
5761

@@ -114,6 +118,7 @@ export default ({config, db}) => async function (req, res, body) {
114118
auth: auth
115119
}, async (_err, _res, _resBody) => { // TODO: add caching layer to speed up SSR? How to invalidate products (checksum on the response BEFORE processing it)
116120
if (_err || _resBody.error) {
121+
console.error(_err || _resBody.error)
117122
apiError(res, _err || _resBody.error)
118123
return
119124
}

src/api/img.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default ({ config, db }) =>
4141
imageBuffer = imageAction.imageBuffer
4242
}
4343

44+
if (res.headersSent) {
45+
return
46+
}
47+
4448
return res
4549
.type(imageAction.mimeType)
4650
.set({ 'Cache-Control': `max-age=${imageAction.maxAgeForResponse}` })

src/api/order.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PlatformFactory from '../platform/factory';
55

66
const Ajv = require('ajv'); // json validator
77
const fs = require('fs');
8+
const path = require('path');
89
const kue = require('kue');
910
const jwa = require('jwa');
1011
const hmac = jwa('HS256');
@@ -29,7 +30,7 @@ export default ({ config, db }) => resource({
2930

3031
const orderSchema = require('../models/order.schema.js')
3132
let orderSchemaExtension = {}
32-
if (fs.existsSync('../models/order.schema.extension.json')) {
33+
if (fs.existsSync(path.resolve(__dirname, '../models/order.schema.extension.json'))) {
3334
orderSchemaExtension = require('../models/order.schema.extension.json')
3435
}
3536
const validate = ajv.compile(merge(orderSchema, orderSchemaExtension));

src/api/product.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default ({ config, db }) => {
2222

2323
if (!req.query.skus) { return apiStatus(res, 'skus parameter is required', 500); }
2424

25-
productProxy.list(req.query.skus.split(',')).then((result) => {
25+
productProxy.list((req.query.skus as string).split(',')).then((result) => {
2626
apiStatus(res, result, 200);
2727
}).catch(err => {
2828
apiError(res, err);
@@ -37,7 +37,7 @@ export default ({ config, db }) => {
3737

3838
if (!req.query.skus) { return apiStatus(res, 'skus parameter is required', 500); }
3939

40-
productProxy.renderList(req.query.skus.split(','), req.query.currencyCode, (req.query.storeId && parseInt(req.query.storeId) > 0) ? req.query.storeId : 1).then((result) => {
40+
productProxy.renderList((req.query.skus as string).split(','), req.query.currencyCode, (req.query.storeId && parseInt((req.query.storeId as string)) > 0) ? req.query.storeId : 1).then((result) => {
4141
result.items = result.items.map((item) => {
4242
let sgnObj = item
4343
if (config.tax.calculateServerSide === true) {

src/api/stock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default ({ config, db }) => {
6565
return apiStatus(res, 'skus parameter is required', 500);
6666
}
6767

68-
const skuArray = req.query.skus.split(',')
68+
const skuArray = (req.query.skus as string).split(',')
6969
const promisesList = []
7070
for (const sku of skuArray) {
7171
promisesList.push(stockProxy.check({sku: sku, stockId: config.msi.enabled ? _getStockId(req.query.storeCode) : null}))

0 commit comments

Comments
 (0)