@openaddresses/batch-schema 4.1.0 → 4.2.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/lib/schema.js +19 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/schema.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Validator } from 'express-json-validator-middleware';
|
|
2
2
|
import { ValidationError } from 'express-json-validator-middleware';
|
|
3
3
|
import $RefParser from 'json-schema-ref-parser';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
4
6
|
|
|
5
7
|
import Err from './error.js';
|
|
6
8
|
import SchemaRoute from '../routes/schema.js';
|
|
@@ -65,6 +67,23 @@ export default class Schemas {
|
|
|
65
67
|
await SchemaRoute(this);
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Load routes directory. All .js files in the given directory will be loaded (ES Module)
|
|
72
|
+
* and the default method run
|
|
73
|
+
*
|
|
74
|
+
* @param {String} dirpath Directory to load
|
|
75
|
+
* @param {object} config Config Object
|
|
76
|
+
* @param {Object} opts Options Object
|
|
77
|
+
* @param {boolean} opts.silent Squelch StdOut
|
|
78
|
+
*/
|
|
79
|
+
async load(dirpath, config, opts = {}) {
|
|
80
|
+
// Load dynamic routes directory
|
|
81
|
+
for (const r of fs.readdirSync(dirpath)) {
|
|
82
|
+
if (!opts.silent) console.error(`ok - loaded routes/${r}`);
|
|
83
|
+
await (await import(path.resolve(dirpath, r))).default(this, config);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
68
87
|
check(url, schemas, fns) {
|
|
69
88
|
if (typeof url !== 'string') throw new Error('URL should be string');
|
|
70
89
|
|
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.2.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>",
|