@openaddresses/batch-schema 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/lib/schema.js +10 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
+
### v4.1.0
|
|
14
|
+
|
|
15
|
+
- :bug: Ensure `default: false` is still applied
|
|
16
|
+
- :arrow_up: Update base deps
|
|
17
|
+
|
|
18
|
+
### v4.0.0
|
|
19
|
+
|
|
20
|
+
- :white_check_mark: Update schema validator to latest version (AJV 8)
|
|
21
|
+
- :rocket: Remove `got` in favour of `fetch`
|
|
22
|
+
|
|
13
23
|
### v3.1.3
|
|
14
24
|
|
|
15
25
|
- :rocket: Add automated releases
|
package/lib/schema.js
CHANGED
|
@@ -35,15 +35,12 @@ class Param {
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* @class
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} router Express Router Object
|
|
40
|
+
* @param {Object} opts Options Object
|
|
41
|
+
* @param {String} opts.schemas Schemas Path
|
|
38
42
|
*/
|
|
39
43
|
export default class Schemas {
|
|
40
|
-
/**
|
|
41
|
-
* @constructor
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} router Express Router Object
|
|
44
|
-
* @param {Object} opts Options Object
|
|
45
|
-
* @param {String} opts.schemas Schemas Path
|
|
46
|
-
*/
|
|
47
44
|
constructor(router, opts = {}) {
|
|
48
45
|
if (!router) throw new Error('Router Param Required');
|
|
49
46
|
|
|
@@ -180,11 +177,13 @@ export default class Schemas {
|
|
|
180
177
|
*/
|
|
181
178
|
static query(schema) {
|
|
182
179
|
return function (req, res, next) {
|
|
183
|
-
for (const key
|
|
180
|
+
for (const key in req.query) {
|
|
184
181
|
if (!schema.properties[key] || !schema.properties[key].type) continue;
|
|
185
182
|
|
|
186
183
|
// For easier processing use consistent array format IE: `type: ["integer", "boolean"]` vs type: "integer"
|
|
187
|
-
if (!Array.isArray(schema.properties[key].type))
|
|
184
|
+
if (!Array.isArray(schema.properties[key].type)) {
|
|
185
|
+
schema.properties[key].type = [schema.properties[key].type];
|
|
186
|
+
}
|
|
188
187
|
|
|
189
188
|
for (const type of schema.properties[key].type) {
|
|
190
189
|
if (type === 'integer' && !isNaN(parseInt(req.query[key]))) {
|
|
@@ -203,8 +202,8 @@ export default class Schemas {
|
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
204
|
|
|
206
|
-
for (const key
|
|
207
|
-
if (req.query[key] === undefined && schema.properties[key].default) {
|
|
205
|
+
for (const key in schema.properties) {
|
|
206
|
+
if (req.query[key] === undefined && schema.properties[key].default !== undefined) {
|
|
208
207
|
req.query[key] = schema.properties[key].default;
|
|
209
208
|
}
|
|
210
209
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"root": true,
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"version": "4.
|
|
6
|
+
"version": "4.1.0",
|
|
7
7
|
"description": "Strongly Validated JSON Schema support for address",
|
|
8
8
|
"repository": "git@github.com:openaddresses/batch-schema",
|
|
9
9
|
"author": "ingalls <nick@ingalls.ca>",
|