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

Commit d3fb13c

Browse files
Merge pull request #217 from DivanteLtd/develop
1.9-rc2 release
2 parents 0097798 + 5d0ad49 commit d3fb13c

File tree

18 files changed

+1181
-981
lines changed

18 files changed

+1181
-981
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,24 @@ 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-rc.2] - unreleased
8+
- Update Babel from 6 to 7 - @lukeromanowicz
9+
- Support unicode characters in order requests - @lukeromanowicz (#201)
10+
- TravisCI configured for building and linting - @lukeromanowicz (#204)
11+
- Use Redis database from configuration in mage2vs - @Cyclonecode (#211)
12+
713
## [1.9.0-rc.1] - 2019.03.04
814
- 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)
915

16+
## [1.8.4] - 2019.04.17
17+
- Use encrypted token for user authentication - @pkarw
18+
19+
## [1.8.3] - 2019.03.05
20+
- Use store id from configuration in `mage2vs import` - @boehsermoe (#179)
21+
22+
## [1.8.2] - 2019.03.04
23+
- Magento 1 bridge client - @afirlejczyk (#190)
24+
- configurable ElasticSearch `apiVersion` - @Resubaka (#192)
25+
1026
## [1.8.1] - 2019.02.11
1127
- 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: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
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": 8,
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",
@@ -88,12 +90,11 @@
8890
"winston": "^2.4.2"
8991
},
9092
"devDependencies": {
91-
"@babel/polyfill": "^7.2.5",
9293
"apollo-server-express": "^1.3.6",
93-
"babel-cli": "^6.26.0",
94-
"babel-core": "^6.26.3",
95-
"babel-preset-env": "^1.7.0",
96-
"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",
9798
"eslint": "^4.16.0",
9899
"nodemon": "^1.18.7"
99100
},

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export default ({ config, db }) => resource({
2424
* POST create an order with JSON payload compliant with models/order.md
2525
*/
2626
create(req, res) {
27-
28-
2927
const ajv = new Ajv();
28+
require('ajv-keywords')(ajv, 'regexp');
29+
3030
const orderSchema = require('../models/order.schema.json')
3131
const orderSchemaExtension = require('../models/order.schema.extension.json')
3232
const validate = ajv.compile(merge(orderSchema, orderSchemaExtension));
@@ -35,7 +35,7 @@ export default ({ config, db }) => resource({
3535
console.dir(validate.errors);
3636
apiStatus(res, validate.errors, 500);
3737
return;
38-
}
38+
}
3939
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 */
4040
console.log(JSON.stringify(incomingOrder))
4141

src/api/user.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { apiStatus } from '../lib/util';
1+
import { apiStatus, encryptToken, decryptToken } from '../lib/util';
22
import { Router } from 'express';
33
import PlatformFactory from '../platform/factory';
44
import jwt from 'jwt-simple';
@@ -68,12 +68,12 @@ export default ({config, db}) => {
6868
*/
6969
if (config.usePriceTiers) {
7070
userProxy.me(result).then((resultMe) => {
71-
apiStatus(res, result, 200, {refreshToken: jwt.encode(req.body, config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
71+
apiStatus(res, result, 200, {refreshToken: encryptToken(jwt.encode(req.body, config.authHashSecret ? config.authHashSecret : config.objHashSecret), config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
7272
}).catch(err => {
7373
apiStatus(res, err, 500);
7474
})
7575
} else {
76-
apiStatus(res, result, 200, {refreshToken: jwt.encode(req.body, config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
76+
apiStatus(res, result, 200, {refreshToken: encryptToken(jwt.encode(req.body, config.authHashSecret ? config.authHashSecret : config.objHashSecret), config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
7777
}
7878
}).catch(err => {
7979
apiStatus(res, err, 500);
@@ -89,16 +89,21 @@ export default ({config, db}) => {
8989
if (!req.body || !req.body.refreshToken) {
9090
return apiStatus(res, 'No refresh token provided', 500);
9191
}
92+
try {
93+
const decodedToken = jwt.decode(req.body ? decryptToken(req.body.refreshToken, config.authHashSecret ? config.authHashSecret : config.objHashSecret) : '', config.authHashSecret ? config.authHashSecret : config.objHashSecret)
9294

93-
const decodedToken = jwt.decode(req.body ? req.body.refreshToken : '', config.authHashSecret ? config.authHashSecret : config.objHashSecret)
94-
if (!decodedToken) {
95-
return apiStatus(res, 'Invalid refresh token provided', 500);
95+
if (!decodedToken) {
96+
return apiStatus(res, 'Invalid refresh token provided', 500);
97+
}
98+
99+
userProxy.login(decodedToken).then((result) => {
100+
apiStatus(res, result, 200, {refreshToken: encryptToken(jwt.encode(decodedToken, config.authHashSecret ? config.authHashSecret : config.objHashSecret), config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
101+
}).catch(err => {
102+
apiStatus(res, err, 500);
103+
})
104+
} catch (err) {
105+
return apiStatus(res, err.message, 500);
96106
}
97-
userProxy.login(decodedToken).then((result) => {
98-
apiStatus(res, result, 200, {refreshToken: jwt.encode(decodedToken, config.authHashSecret ? config.authHashSecret : config.objHashSecret)});
99-
}).catch(err => {
100-
apiStatus(res, err, 500);
101-
})
102107
});
103108

104109
/**

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)