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

Commit b0dd9db

Browse files
Merge pull request #233 from DivanteLtd/release/v1.9
Release/v1.9
2 parents 64c8f0d + 8d00e0a commit b0dd9db

38 files changed

+1337
-1571
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
sudo: required
2+
language: node_js
3+
4+
cache:
5+
yarn: true
6+
directories:
7+
- node_modules
8+
9+
install:
10+
- yarn
11+
12+
jobs:
13+
include:
14+
- stage: Build
15+
script:
16+
- yarn lint
17+
- yarn build
18+
node_js: "8"
19+
- script:
20+
- yarn lint
21+
- yarn build
22+
node_js: "10"

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
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

7+
## [1.9.0] - 2019.05.06
8+
- Changed location of magento1 platform js client. Moved from `src/platform/magento1/module` to [magento1-vsbridge-client](https://github.com/DivanteLtd/magento1-vsbridge-client) - @mtarld (#195)
9+
- Update Babel from 6 to 7 - @lukeromanowicz
10+
- Support unicode characters in order requests - @lukeromanowicz (#201)
11+
- TravisCI configured for building and linting - @lukeromanowicz (#204)
12+
- Use Redis database from configuration in mage2vs - @Cyclonecode (#211)
13+
- Requests with invalid body result in HTTP code 400 instead of 500 - @AndreiBelokopytov (#220)
14+
- `src/models/order.schema.json` was moved to `src/models/order.schema.js` to support regex transformation - @lukeromanowicz (#201)
15+
716
## [1.8.4] - 2019.04.17
817
- Use encrypted token for user authentication - @pkarw
918

@@ -14,6 +23,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1423
- Magento 1 bridge client - @afirlejczyk (#190)
1524
- configurable ElasticSearch `apiVersion` - @Resubaka (#192)
1625

17-
1826
## [1.8.1] - 2019.02.11
1927
- Fixed `apiVersion` property for ElasticSearch driver - now it's available thru `config/*.json` - @mdanilowicz (#185)

babel.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env', {
5+
targets: {
6+
node: "8"
7+
}
8+
}
9+
]
10+
]
11+
};

docker-compose.nodejs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
- './ecosystem.json:/var/www/ecosystem.json'
1717
- './migrations:/var/www/migrations'
1818
- './package.json:/var/www/package.json'
19+
- './babel.config.js:/var/www/babel.config.js'
1920
- './scripts:/var/www/scripts'
2021
- './src:/var/www/src'
2122
- './var:/var/www/var'

migrations/1530101328854-local_es_config_fix.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ var files = fs.readdirSync(configDir).filter(function(file) {
1717

1818
module.exports.up = next => {
1919
files.forEach(function(file) {
20-
var file = path.join(configDir, file)
20+
var path = path.join(configDir, file)
2121

2222
try {
23-
console.log(`Searching for deprecated parameters in file '${file}'...`)
24-
let config = JSON.parse(fs.readFileSync(file))
23+
console.log(`Searching for deprecated parameters in file '${path}'...`)
24+
let config = JSON.parse(fs.readFileSync(path))
2525

2626
if ("esHost" in config) {
27-
console.log("Parameter 'esHost' found - rewriting...", file)
27+
console.log("Parameter 'esHost' found - rewriting...", path)
2828
let esHostPort = config.esHost.split(':')
2929
_set(config, 'elasticsearch.host', esHostPort[0])
3030
_set(config, 'elasticsearch.port', esHostPort[1])
@@ -37,8 +37,8 @@ module.exports.up = next => {
3737
delete config.esIndexes
3838
}
3939

40-
fs.writeFileSync(file, JSON.stringify(config, null, 2))
41-
console.log(`File '${file}' updated.`)
40+
fs.writeFileSync(path, JSON.stringify(config, null, 2))
41+
console.log(`File '${path}' updated.`)
4242
} catch (e) {
4343
throw e
4444
}

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "vue-storefront-api",
3-
"version": "0.1.0",
3+
"version": "1.9.0",
44
"private": true,
55
"description": "vue-storefront API and data services",
66
"main": "dist",
77
"scripts": {
8-
"dev": "nodemon -w src --exec \"babel-node src --presets env,stage-0\"",
9-
"build": "babel src -s -D -d dist --presets env,stage-0",
8+
"dev": "nodemon -w src --exec \"babel-node src\"",
9+
"build": "babel src -s -D -d dist",
1010
"start": "pm2 start ecosystem.json $PM2_ARGS",
1111
"db": "node scripts/db.js",
1212
"seo": "node scripts/seo.js",
@@ -33,11 +33,12 @@
3333
"eslintConfig": {
3434
"extends": "eslint:recommended",
3535
"parserOptions": {
36-
"ecmaVersion": 7,
36+
"ecmaVersion": 2018,
3737
"sourceType": "module"
3838
},
3939
"env": {
40-
"node": true
40+
"node": true,
41+
"es6": true
4142
},
4243
"rules": {
4344
"no-console": 0,
@@ -52,6 +53,7 @@
5253
"license": "MIT",
5354
"dependencies": {
5455
"ajv": "^6.4.0",
56+
"ajv-keywords": "^3.4.0",
5557
"body-parser": "^1.18.2",
5658
"bodybuilder": "2.2.13",
5759
"commander": "^2.19.0",
@@ -71,6 +73,7 @@
7173
"kue": "^0.11.6",
7274
"lodash": "^4.17.10",
7375
"mage2vuestorefront": "git+https://github.com/DivanteLtd/mage2vuestorefront.git",
76+
"magento1-vsbridge-client": "github:DivanteLtd/magento1-vsbridge-client",
7477
"magento2-rest-client": "github:DivanteLtd/magento2-rest-client",
7578
"merge-graphql-schemas": "^1.5.2",
7679
"migrate": "^1.6.2",
@@ -87,12 +90,11 @@
8790
"winston": "^2.4.2"
8891
},
8992
"devDependencies": {
90-
"@babel/polyfill": "^7.2.5",
9193
"apollo-server-express": "^1.3.6",
92-
"babel-cli": "^6.26.0",
93-
"babel-core": "^6.26.3",
94-
"babel-preset-env": "^1.7.0",
95-
"babel-preset-stage-0": "^6.24.1",
94+
"@babel/cli": "^7.2.3",
95+
"@babel/core": "^7.4.0",
96+
"@babel/node": "^7.2.2",
97+
"@babel/preset-env": "^7.4.2",
9698
"eslint": "^4.16.0",
9799
"nodemon": "^1.18.7"
98100
},

scripts/mage2vs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function getMagentoDefaultConfig(storeCode) {
3838
MAGENTO_URL: apiConfig.url,
3939
REDIS_HOST: config.redis.host,
4040
REDIS_PORT: config.redis.port,
41+
REDIS_DB: config.redis.db,
4142
INDEX_NAME: config.elasticsearch.indices[0],
4243
DATABASE_URL: `${config.elasticsearch.protocol}://${config.elasticsearch.host}:${config.elasticsearch.port}`
4344
}

src/api/order.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ export default ({ config, db }) => resource({
2424
* POST create an order with JSON payload compliant with models/order.md
2525
*/
2626
create(req, res) {
27-
2827

2928
const ajv = new Ajv();
30-
const orderSchema = require('../models/order.schema.json')
29+
require('ajv-keywords')(ajv, 'regexp');
30+
31+
const orderSchema = require('../models/order.schema.js')
3132
const orderSchemaExtension = require('../models/order.schema.extension.json')
3233
const validate = ajv.compile(merge(orderSchema, orderSchemaExtension));
3334

3435
if (!validate(req.body)) { // schema validation of upcoming order
3536
console.dir(validate.errors);
36-
apiStatus(res, validate.errors, 500);
37+
apiStatus(res, validate.errors, 400);
3738
return;
38-
}
39+
}
3940
const incomingOrder = { title: 'Incoming order received on ' + new Date() + ' / ' + req.ip, ip: req.ip, agent: req.headers['user-agent'], receivedAt: new Date(), order: req.body }/* parsed using bodyParser.json middleware */
4041
console.log(JSON.stringify(incomingOrder))
4142

@@ -47,7 +48,7 @@ export default ({ config, db }) => resource({
4748
key.sku = product.sku
4849
}
4950
// console.log(key)
50-
51+
5152
if (!config.tax.usePlatformTotals) {
5253
if (!hmac.verify(key, product.sgn, config.objHashSecret)) {
5354
console.error('Invalid hash for ' + product.sku + ': ' + product.sgn)

src/api/user.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ export default ({config, db}) => {
9191
}
9292
try {
9393
const decodedToken = jwt.decode(req.body ? decryptToken(req.body.refreshToken, config.authHashSecret ? config.authHashSecret : config.objHashSecret) : '', config.authHashSecret ? config.authHashSecret : config.objHashSecret)
94-
if (!decodedToken) {
94+
95+
if (!decodedToken) {
9596
return apiStatus(res, 'Invalid refresh token provided', 500);
9697
}
98+
9799
userProxy.login(decodedToken).then((result) => {
98100
apiStatus(res, result, 200, {refreshToken: encryptToken(jwt.encode(decodedToken, config.authHashSecret ? config.authHashSecret : config.objHashSecret), config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
99101
}).catch(err => {
100102
apiStatus(res, err, 500);
101-
})
103+
})
102104
} catch (err) {
103105
return apiStatus(res, err.message, 500);
104106
}

src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import '@babel/polyfill/noConflict';
21
import http from 'http';
32
import express from 'express';
43
import cors from 'cors';

0 commit comments

Comments
 (0)