@openaddresses/batch-schema 4.4.0 → 5.0.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 +4 -0
- package/lib/schema.js +11 -2
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
package/lib/schema.js
CHANGED
|
@@ -3,6 +3,8 @@ import { ValidationError } from 'express-json-validator-middleware';
|
|
|
3
3
|
import $RefParser from 'json-schema-ref-parser';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import morgan from 'morgan';
|
|
7
|
+
import bodyparser from 'body-parser';
|
|
6
8
|
|
|
7
9
|
import Err from './error.js';
|
|
8
10
|
import SchemaRoute from '../routes/schema.js';
|
|
@@ -41,6 +43,8 @@ class Param {
|
|
|
41
43
|
* @param {Object} router Express Router Object
|
|
42
44
|
* @param {Object} opts Options Object
|
|
43
45
|
* @param {String} opts.schemas Schemas Path
|
|
46
|
+
* @param {boolean|string} [opts.logging=true] disable logging with false
|
|
47
|
+
* @param {number} [opts.limit=50] body size limit in mb
|
|
44
48
|
*/
|
|
45
49
|
export default class Schemas {
|
|
46
50
|
constructor(router, opts = {}) {
|
|
@@ -49,8 +53,8 @@ export default class Schemas {
|
|
|
49
53
|
if (!opts.schemas) {
|
|
50
54
|
this.schemas_path = new URL('../schema/', import.meta.url).pathname;
|
|
51
55
|
} else {
|
|
52
|
-
if (
|
|
53
|
-
else
|
|
56
|
+
if (opts.schemas instanceof URL) opts.schemas = opts.schemas.pathname;
|
|
57
|
+
else opts.schemas = String(opts.schemas);
|
|
54
58
|
|
|
55
59
|
this.schemas_path = opts.schemas;
|
|
56
60
|
}
|
|
@@ -62,6 +66,11 @@ export default class Schemas {
|
|
|
62
66
|
});
|
|
63
67
|
|
|
64
68
|
this.router = router;
|
|
69
|
+
|
|
70
|
+
if (opts.morgan !== false) this.router.use(morgan('combined'));
|
|
71
|
+
this.router.use(bodyparser.urlencoded({ extended: true }));
|
|
72
|
+
this.router.use(bodyparser.json({ limit: `${opts.limit}mb` }));
|
|
73
|
+
|
|
65
74
|
this.schemas = new Map();
|
|
66
75
|
this.validate = this.validator.validate;
|
|
67
76
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"root": true,
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "5.0.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>",
|
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"ajv": "^8.6.3",
|
|
22
|
+
"body-parser": "^1.20.0",
|
|
22
23
|
"express": "^4.17.1",
|
|
23
24
|
"express-json-validator-middleware": "^3.0.0",
|
|
24
25
|
"glob": "^8.0.0",
|
|
25
26
|
"json-schema-ref-parser": "^9.0.9",
|
|
27
|
+
"morgan": "^1.10.0",
|
|
26
28
|
"tape": "^5.3.1"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|