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

Commit fc462cf

Browse files
Merge pull request #262 from DivanteLtd/release/v1.9
Release/v1.9.4
2 parents fe9d783 + 5d68ec0 commit fc462cf

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ 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.4] - 2019.06.03
8+
- extension schemas for order as not required anymore - @EmilsM, @lukeromanowicz (#259, #263)
9+
710
## [1.9.3] - 2019.05.27
811
- Change min postal code length in user profile to 3 so it's sames as in orders - @lukeromanowicz (#253)
912

src/api/order.js

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

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

3132
const orderSchema = require('../models/order.schema.js')
32-
const orderSchemaExtension = require('../models/order.schema.extension.json')
33+
let orderSchemaExtension = {}
34+
if(fs.existsSync('../models/order.schema.extension.json')) {
35+
orderSchemaExtension = require('../models/order.schema.extension.json')
36+
}
3337
const validate = ajv.compile(merge(orderSchema, orderSchemaExtension));
3438

3539
if (!validate(req.body)) { // schema validation of upcoming order

src/api/user.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import jwt from 'jwt-simple';
55
import { merge } from 'lodash';
66

77
const Ajv = require('ajv'); // json validator
8+
const fs = require('fs');
89

910
function addUserGroupToken(config, result) {
1011
/**
@@ -38,7 +39,10 @@ export default ({config, db}) => {
3839

3940
const ajv = new Ajv();
4041
const userRegisterSchema = require('../models/userRegister.schema.json')
41-
const userRegisterSchemaExtension = require('../models/userRegister.schema.extension.json')
42+
let userRegisterSchemaExtension = {};
43+
if(fs.existsSync('../models/userRegister.schema.extension.json')) {
44+
userRegisterSchemaExtension = require('../models/userRegister.schema.extension.json');
45+
}
4246
const validate = ajv.compile(merge(userRegisterSchema, userRegisterSchemaExtension))
4347

4448
if (!validate(req.body)) { // schema validation of upcoming order
@@ -171,7 +175,10 @@ export default ({config, db}) => {
171175
userApi.post('/me', (req, res) => {
172176
const ajv = new Ajv();
173177
const userProfileSchema = require('../models/userProfile.schema.json')
174-
const userProfileSchemaExtension = require('../models/userProfile.schema.extension.json')
178+
let userProfileSchemaExtension = {};
179+
if(fs.existsSync('../models/userProfile.schema.extension.json')) {
180+
userProfileSchemaExtension = require('../models/userProfile.schema.extension.json');
181+
}
175182
const validate = ajv.compile(merge(userProfileSchema, userProfileSchemaExtension))
176183

177184
if (req.body.customer && req.body.customer.groupToken) {

src/platform/magento2/o2m.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ redisClient.on('error', function (err) { // workaround for https://github.com/No
1010
});
1111
const countryMapper = require('../../lib/countrymapper')
1212
const Ajv = require('ajv'); // json validator
13+
const fs = require('fs');
1314
const ajv = new Ajv(); // validator
1415
const merge = require('lodash/merge')
1516
const orderSchema = require('../../models/order.schema.js')
16-
const orderSchemaExtension = require('../../models/order.schema.extension.json')
17+
let orderSchemaExtension = {}
18+
if(fs.existsSync('../../models/order.schema.extension.json')) {
19+
orderSchemaExtension = require('../../models/order.schema.extension.json')
20+
}
1721
const validate = ajv.compile(merge(orderSchema, orderSchemaExtension));
1822

1923
function isNumeric(val) {

0 commit comments

Comments
 (0)