@openaddresses/batch-schema 4.2.0 → 4.3.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 +5 -0
- package/README.md +15 -0
- package/lib/schema.js +21 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -94,3 +94,18 @@ express compatible responses.
|
|
|
94
94
|
```
|
|
95
95
|
schema.error()
|
|
96
96
|
```
|
|
97
|
+
|
|
98
|
+
### schema.load
|
|
99
|
+
|
|
100
|
+
Loads and runs all routes files in a directory
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
schema.load(directory, config, opts)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
| Config Option | Notes |
|
|
107
|
+
| ----------------- | ----- |
|
|
108
|
+
| `directory` | Directory to load .js files from |
|
|
109
|
+
| `config` | Config option to pass to each route |
|
|
110
|
+
| `opts` | Optional Opts Object |
|
|
111
|
+
| `opts.silent` | Squelch output |
|
package/lib/schema.js
CHANGED
|
@@ -205,12 +205,30 @@ export default class Schemas {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
for (const type of schema.properties[key].type) {
|
|
208
|
-
if (type === '
|
|
208
|
+
if (type === 'array') {
|
|
209
|
+
req.query[key] = req.query[key].split(',');
|
|
210
|
+
|
|
211
|
+
if (schema.properties[key].items && schema.properties[key].items.type === 'number') {
|
|
212
|
+
req.query[key] = req.query[key].map((k) => {
|
|
213
|
+
return Number(k);
|
|
214
|
+
});
|
|
215
|
+
} else if (schema.properties[key].items && schema.properties[key].items.type === 'integer') {
|
|
216
|
+
req.query[key] = req.query[key].map((k) => {
|
|
217
|
+
return parseInt(k);
|
|
218
|
+
});
|
|
219
|
+
} else if (schema.properties[key].items && schema.properties[key].items.type === 'boolean') {
|
|
220
|
+
req.query[key] = req.query[key].map((k) => {
|
|
221
|
+
if (k === 'true') {
|
|
222
|
+
return true;
|
|
223
|
+
} else if (k === 'false') {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
} else if (type === 'integer' && !isNaN(parseInt(req.query[key]))) {
|
|
209
229
|
req.query[key] = parseInt(req.query[key]);
|
|
210
230
|
} else if (type === 'number' && !isNaN(Number(req.query[key]))) {
|
|
211
231
|
req.query[key] = Number(req.query[key]);
|
|
212
|
-
} else if (type === 'array') {
|
|
213
|
-
req.query[key] = req.query[key].split(',');
|
|
214
232
|
} else if (type === 'boolean') {
|
|
215
233
|
if (req.query[key] === 'true') {
|
|
216
234
|
req.query[key] = true;
|
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.3.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>",
|