@openaddresses/batch-schema 6.0.0 → 7.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 CHANGED
@@ -10,6 +10,11 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v7.0.0
14
+
15
+ - :rocket: Remove PublicError class to it's own package
16
+ - :rocket: `Schema` is now exposed as the default
17
+
13
18
  ### v6.0.0
14
19
 
15
20
  - :rocket: Remove additional properties if they are not present in `res` and `additionalProperties: false` is set
package/index.js CHANGED
@@ -1,7 +1,3 @@
1
1
  import Schema from './lib/schema.js';
2
- import Err from './lib/error.js';
3
2
 
4
- export {
5
- Schema,
6
- Err
7
- };
3
+ export default Schema;
package/lib/middleware.js CHANGED
@@ -1,4 +1,4 @@
1
- import Err from './error.js';
1
+ import Err from '@openaddresses/batch-error';
2
2
  import Param from './param.js';
3
3
  import Ajv from 'ajv';
4
4
  import addFormats from 'ajv-formats';
package/lib/param.js CHANGED
@@ -1,4 +1,4 @@
1
- import Err from './error.js';
1
+ import Err from '@openaddresses/batch-error';
2
2
 
3
3
  /**
4
4
  * @class
package/lib/schema.js CHANGED
@@ -148,7 +148,6 @@ export default class Schemas {
148
148
 
149
149
  flow[1].push(this.validate(opts));
150
150
 
151
- console.error(schemas);
152
151
  if (schemas.res) flow[1].push(Middleware.res(schemas.res));
153
152
 
154
153
  return flow;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "root": true,
5
5
  "main": "index.js",
6
- "version": "6.0.0",
6
+ "version": "7.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>",
@@ -18,6 +18,7 @@
18
18
  "doc": "documentation build index.js -f html -o docs && documentation lint index.js"
19
19
  },
20
20
  "dependencies": {
21
+ "@openaddresses/batch-error": "^1.0.1",
21
22
  "ajv": "^8.6.3",
22
23
  "ajv-formats": "^2.1.1",
23
24
  "body-parser": "^1.20.0",
package/routes/schema.js CHANGED
@@ -1,4 +1,4 @@
1
- import Err from '../lib/error.js';
1
+ import Err from '@openaddresses/batch-error';
2
2
 
3
3
  export default async function router(schema) {
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import test from 'tape';
2
2
  import express from 'express';
3
- import { Schema } from '../index.js';
3
+ import Schema from '../index.js';
4
4
 
5
5
  const app = express();
6
6
  const schema = new Schema(express.Router(), {
package/lib/error.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * @class
3
- */
4
- export default class PublicError {
5
- constructor(status, err, safe, print = true) {
6
- // Wrap postgres errors to ensure stack trace (line nums) are returned
7
- if (err && err.severity) err = new Error(err);
8
-
9
- if (print && ![400, 401, 402, 403, 404].includes(status)) console.error(err ? err : 'Error: ' + safe);
10
-
11
- this.status = status;
12
- this.err = err;
13
- this.safe = safe;
14
- }
15
-
16
- static respond(err, res, messages = []) {
17
- if (err instanceof PublicError) {
18
- res.status(err.status).json({
19
- status: err.status,
20
- message: err.safe,
21
- messages: messages
22
- });
23
-
24
- // Duplicate Express supported Error extensions
25
- } else if (err instanceof Error && (err.status || err.statusCode)) {
26
- res.status(err.status || err.statusCode).json({
27
- status: err.status || err.statusCode,
28
- message: err.message || 'Generic Error',
29
- messages: messages
30
- });
31
-
32
- // Handle generic errors
33
- } else {
34
- console.error(err);
35
-
36
- res.status(500).json({
37
- status: 500,
38
- message: 'Internal Server Error',
39
- messages: messages
40
- });
41
- }
42
- }
43
- }