@donmahallem/turbo-validate-request 0.4.4 → 0.4.7

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.
@@ -1,25 +1,24 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const turbo = require('@donmahallem/turbo');
6
4
 
7
- /*
8
- * Package @donmahallem/turbo-validate-request
9
- * Source https://donmahallem.github.io/js-libs/
10
- */
11
- const convertValidationError = (error) => {
12
- const errorPath = error.instancePath === '' ? 'root' : error.instancePath;
13
- switch (error.keyword) {
14
- case 'required':
15
- return new turbo.RequestError(`Missing property ${error.params.missingProperty} at '${errorPath}'`, 400);
16
- case 'pattern':
17
- return new turbo.RequestError(`Value doesn't match pattern at: '${errorPath}'`, 400);
18
- case 'type':
19
- return new turbo.RequestError(`Invalid type at '${errorPath}'. Expected ${error.params.type}`, 400);
20
- default:
21
- return new turbo.RequestError(`Invalid '${errorPath}'`, 400);
22
- }
5
+ /*
6
+ * Package @donmahallem/turbo-validate-request
7
+ * Source https://donmahallem.github.io/js-libs/
8
+ */
9
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
10
+ const convertValidationError = (error) => {
11
+ const errorPath = error.instancePath === '' ? 'root' : error.instancePath;
12
+ switch (error.keyword) {
13
+ case 'required':
14
+ return new turbo.RequestError(`Missing property ${error.params.missingProperty} at '${errorPath}'`, 400);
15
+ case 'pattern':
16
+ return new turbo.RequestError(`Value doesn't match pattern at: '${errorPath}'`, 400);
17
+ case 'type':
18
+ return new turbo.RequestError(`Invalid type at '${errorPath}'. Expected ${error.params.type}`, 400);
19
+ default:
20
+ return new turbo.RequestError(`Invalid '${errorPath}'`, 400);
21
+ }
23
22
  };
24
23
 
25
24
  exports.convertValidationError = convertValidationError;
@@ -1 +1 @@
1
- {"version":3,"file":"convert-validation-error.cjs","sources":["../../src/convert-validation-error.ts"],"sourcesContent":[null],"names":["RequestError"],"mappings":";;;;;;AAAA;;;AAGG;AAKU,MAAA,sBAAsB,GAA0C,CAAC,KAAmB,KAAkB;AAC/G,IAAA,MAAM,SAAS,GAAW,KAAK,CAAC,YAAY,KAAK,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;IAClF,QAAQ,KAAK,CAAC,OAAO;AACjB,QAAA,KAAK,UAAU;AACX,YAAA,OAAO,IAAIA,kBAAY,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAC,MAAM,CAAC,eAAe,QAAQ,SAAS,CAAA,CAAA,CAAG,EAAE,GAAG,CAAC,CAAC;AACvG,QAAA,KAAK,SAAS;YACV,OAAO,IAAIA,kBAAY,CAAC,CAAA,iCAAA,EAAoC,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AACnF,QAAA,KAAK,MAAM;AACP,YAAA,OAAO,IAAIA,kBAAY,CAAC,CAAA,iBAAA,EAAoB,SAAS,CAAe,YAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,CAAC,CAAC;AAClG,QAAA;YACI,OAAO,IAAIA,kBAAY,CAAC,CAAA,SAAA,EAAY,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AAC9D,KAAA;AACL;;;;"}
1
+ {"version":3,"file":"convert-validation-error.cjs","sources":["../../src/convert-validation-error.ts"],"sourcesContent":[null],"names":["RequestError"],"mappings":";;;;AAAA;;;AAGG;AAKH;AACa,MAAA,sBAAsB,GAA0C,CAAC,KAAmB,KAAkB;AAC/G,IAAA,MAAM,SAAS,GAAW,KAAK,CAAC,YAAY,KAAK,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;AAClF,IAAA,QAAQ,KAAK,CAAC,OAAO;AACjB,QAAA,KAAK,UAAU;AACX,YAAA,OAAO,IAAIA,kBAAY,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAC,MAAM,CAAC,eAAe,QAAQ,SAAS,CAAA,CAAA,CAAG,EAAE,GAAG,CAAC,CAAC;AACvG,QAAA,KAAK,SAAS;YACV,OAAO,IAAIA,kBAAY,CAAC,CAAA,iCAAA,EAAoC,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AACnF,QAAA,KAAK,MAAM;AACP,YAAA,OAAO,IAAIA,kBAAY,CAAC,CAAA,iBAAA,EAAoB,SAAS,CAAe,YAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,CAAC,CAAC;AAClG,QAAA;YACI,OAAO,IAAIA,kBAAY,CAAC,CAAA,SAAA,EAAY,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;KAC9D;AACL;;;;"}
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const validateRequest = require('./validate-request.cjs');
6
4
 
7
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,36 +1,29 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const Ajv = require('ajv');
6
4
  const convertValidationError = require('./convert-validation-error.cjs');
7
5
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- const Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
11
-
12
- /*
13
- * Package @donmahallem/turbo-validate-request
14
- * Source https://donmahallem.github.io/js-libs/
15
- */
16
- /**
17
- * Checks a request against the given schema
18
- *
19
- * @param {string} key property of the request to check the schema against
20
- * @param {JSONSchemaType} schema the jsonschema
21
- * @param {Ajv} ajvInstance optional ajv to be used
22
- * @returns {RequestHandler} express middleware
23
- */
24
- const validateRequest = (key, schema, ajvInstance = new Ajv__default["default"]()) => {
25
- const validateFunction = ajvInstance.compile(schema);
26
- return (req, res, next) => {
27
- if (!validateFunction(req[key])) {
28
- const errors = validateFunction.errors;
29
- next(convertValidationError.convertValidationError(errors[0]));
30
- return;
31
- }
32
- next();
33
- };
6
+ /*
7
+ * Package @donmahallem/turbo-validate-request
8
+ * Source https://donmahallem.github.io/js-libs/
9
+ */
10
+ /**
11
+ * Checks a request against the given schema
12
+ * @param {string} key property of the request to check the schema against
13
+ * @param {JSONSchemaType} schema the jsonschema
14
+ * @param {Ajv} ajvInstance optional ajv to be used
15
+ * @returns {RequestHandler} express middleware
16
+ */
17
+ const validateRequest = (key, schema, ajvInstance = new Ajv()) => {
18
+ const validateFunction = ajvInstance.compile(schema);
19
+ return (req, res, next) => {
20
+ if (!validateFunction(req[key])) {
21
+ const errors = validateFunction.errors;
22
+ next(convertValidationError.convertValidationError(errors[0]));
23
+ return;
24
+ }
25
+ next();
26
+ };
34
27
  };
35
28
 
36
29
  exports.validateRequest = validateRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"validate-request.cjs","sources":["../../src/validate-request.ts"],"sourcesContent":[null],"names":["Ajv","convertValidationError"],"mappings":";;;;;;;;;;;AAAA;;;AAGG;AAQH;;;;;;;AAOG;AACI,MAAM,eAAe,GAAoB,CAC5C,GAAc,EACd,MAAyB,EACzB,WAAmB,GAAA,IAAIA,uBAAG,EAAE,KACZ;IAChB,MAAM,gBAAgB,GAAqB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvE,IAAA,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,KAAU;QAC7D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;AAC7B,YAAA,MAAM,MAAM,GAAmB,gBAAgB,CAAC,MAAwB,CAAC;YACzE,IAAI,CAACC,6CAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO;AACV,SAAA;AACD,QAAA,IAAI,EAAE,CAAC;AACX,KAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"validate-request.cjs","sources":["../../src/validate-request.ts"],"sourcesContent":[null],"names":["convertValidationError"],"mappings":";;;;;AAAA;;;AAGG;AAQH;;;;;;AAMG;AACI,MAAM,eAAe,GAAoB,CAC5C,GAAc,EACd,MAAyB,EACzB,WAAmB,GAAA,IAAI,GAAG,EAAE,KACZ;IAChB,MAAM,gBAAgB,GAAqB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvE,IAAA,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,KAAU;QAC7D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;AAC7B,YAAA,MAAM,MAAM,GAAmB,gBAAgB,CAAC,MAAwB,CAAC;YACzE,IAAI,CAACA,6CAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO;SACV;AACD,QAAA,IAAI,EAAE,CAAC;AACX,KAAC,CAAC;AACN;;;;"}
@@ -1,21 +1,22 @@
1
1
  import { RequestError } from '@donmahallem/turbo';
2
2
 
3
- /*
4
- * Package @donmahallem/turbo-validate-request
5
- * Source https://donmahallem.github.io/js-libs/
6
- */
7
- const convertValidationError = (error) => {
8
- const errorPath = error.instancePath === '' ? 'root' : error.instancePath;
9
- switch (error.keyword) {
10
- case 'required':
11
- return new RequestError(`Missing property ${error.params.missingProperty} at '${errorPath}'`, 400);
12
- case 'pattern':
13
- return new RequestError(`Value doesn't match pattern at: '${errorPath}'`, 400);
14
- case 'type':
15
- return new RequestError(`Invalid type at '${errorPath}'. Expected ${error.params.type}`, 400);
16
- default:
17
- return new RequestError(`Invalid '${errorPath}'`, 400);
18
- }
3
+ /*
4
+ * Package @donmahallem/turbo-validate-request
5
+ * Source https://donmahallem.github.io/js-libs/
6
+ */
7
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
8
+ const convertValidationError = (error) => {
9
+ const errorPath = error.instancePath === '' ? 'root' : error.instancePath;
10
+ switch (error.keyword) {
11
+ case 'required':
12
+ return new RequestError(`Missing property ${error.params.missingProperty} at '${errorPath}'`, 400);
13
+ case 'pattern':
14
+ return new RequestError(`Value doesn't match pattern at: '${errorPath}'`, 400);
15
+ case 'type':
16
+ return new RequestError(`Invalid type at '${errorPath}'. Expected ${error.params.type}`, 400);
17
+ default:
18
+ return new RequestError(`Invalid '${errorPath}'`, 400);
19
+ }
19
20
  };
20
21
 
21
22
  export { convertValidationError };
@@ -1 +1 @@
1
- {"version":3,"file":"convert-validation-error.mjs","sources":["../../src/convert-validation-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAKU,MAAA,sBAAsB,GAA0C,CAAC,KAAmB,KAAkB;AAC/G,IAAA,MAAM,SAAS,GAAW,KAAK,CAAC,YAAY,KAAK,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;IAClF,QAAQ,KAAK,CAAC,OAAO;AACjB,QAAA,KAAK,UAAU;AACX,YAAA,OAAO,IAAI,YAAY,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAC,MAAM,CAAC,eAAe,QAAQ,SAAS,CAAA,CAAA,CAAG,EAAE,GAAG,CAAC,CAAC;AACvG,QAAA,KAAK,SAAS;YACV,OAAO,IAAI,YAAY,CAAC,CAAA,iCAAA,EAAoC,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AACnF,QAAA,KAAK,MAAM;AACP,YAAA,OAAO,IAAI,YAAY,CAAC,CAAA,iBAAA,EAAoB,SAAS,CAAe,YAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,CAAC,CAAC;AAClG,QAAA;YACI,OAAO,IAAI,YAAY,CAAC,CAAA,SAAA,EAAY,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AAC9D,KAAA;AACL;;;;"}
1
+ {"version":3,"file":"convert-validation-error.mjs","sources":["../../src/convert-validation-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAKH;AACa,MAAA,sBAAsB,GAA0C,CAAC,KAAmB,KAAkB;AAC/G,IAAA,MAAM,SAAS,GAAW,KAAK,CAAC,YAAY,KAAK,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;AAClF,IAAA,QAAQ,KAAK,CAAC,OAAO;AACjB,QAAA,KAAK,UAAU;AACX,YAAA,OAAO,IAAI,YAAY,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAC,MAAM,CAAC,eAAe,QAAQ,SAAS,CAAA,CAAA,CAAG,EAAE,GAAG,CAAC,CAAC;AACvG,QAAA,KAAK,SAAS;YACV,OAAO,IAAI,YAAY,CAAC,CAAA,iCAAA,EAAoC,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;AACnF,QAAA,KAAK,MAAM;AACP,YAAA,OAAO,IAAI,YAAY,CAAC,CAAA,iBAAA,EAAoB,SAAS,CAAe,YAAA,EAAA,KAAK,CAAC,MAAM,CAAC,IAAI,CAAA,CAAE,EAAE,GAAG,CAAC,CAAC;AAClG,QAAA;YACI,OAAO,IAAI,YAAY,CAAC,CAAA,SAAA,EAAY,SAAS,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;KAC9D;AACL;;;;"}
@@ -1,28 +1,27 @@
1
1
  import Ajv from 'ajv';
2
2
  import { convertValidationError } from './convert-validation-error.mjs';
3
3
 
4
- /*
5
- * Package @donmahallem/turbo-validate-request
6
- * Source https://donmahallem.github.io/js-libs/
7
- */
8
- /**
9
- * Checks a request against the given schema
10
- *
11
- * @param {string} key property of the request to check the schema against
12
- * @param {JSONSchemaType} schema the jsonschema
13
- * @param {Ajv} ajvInstance optional ajv to be used
14
- * @returns {RequestHandler} express middleware
15
- */
16
- const validateRequest = (key, schema, ajvInstance = new Ajv()) => {
17
- const validateFunction = ajvInstance.compile(schema);
18
- return (req, res, next) => {
19
- if (!validateFunction(req[key])) {
20
- const errors = validateFunction.errors;
21
- next(convertValidationError(errors[0]));
22
- return;
23
- }
24
- next();
25
- };
4
+ /*
5
+ * Package @donmahallem/turbo-validate-request
6
+ * Source https://donmahallem.github.io/js-libs/
7
+ */
8
+ /**
9
+ * Checks a request against the given schema
10
+ * @param {string} key property of the request to check the schema against
11
+ * @param {JSONSchemaType} schema the jsonschema
12
+ * @param {Ajv} ajvInstance optional ajv to be used
13
+ * @returns {RequestHandler} express middleware
14
+ */
15
+ const validateRequest = (key, schema, ajvInstance = new Ajv()) => {
16
+ const validateFunction = ajvInstance.compile(schema);
17
+ return (req, res, next) => {
18
+ if (!validateFunction(req[key])) {
19
+ const errors = validateFunction.errors;
20
+ next(convertValidationError(errors[0]));
21
+ return;
22
+ }
23
+ next();
24
+ };
26
25
  };
27
26
 
28
27
  export { validateRequest };
@@ -1 +1 @@
1
- {"version":3,"file":"validate-request.mjs","sources":["../../src/validate-request.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;AAGG;AAQH;;;;;;;AAOG;AACI,MAAM,eAAe,GAAoB,CAC5C,GAAc,EACd,MAAyB,EACzB,WAAmB,GAAA,IAAI,GAAG,EAAE,KACZ;IAChB,MAAM,gBAAgB,GAAqB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvE,IAAA,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,KAAU;QAC7D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;AAC7B,YAAA,MAAM,MAAM,GAAmB,gBAAgB,CAAC,MAAwB,CAAC;YACzE,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO;AACV,SAAA;AACD,QAAA,IAAI,EAAE,CAAC;AACX,KAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"validate-request.mjs","sources":["../../src/validate-request.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;AAGG;AAQH;;;;;;AAMG;AACI,MAAM,eAAe,GAAoB,CAC5C,GAAc,EACd,MAAyB,EACzB,WAAmB,GAAA,IAAI,GAAG,EAAE,KACZ;IAChB,MAAM,gBAAgB,GAAqB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACvE,IAAA,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,KAAU;QAC7D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE;AAC7B,YAAA,MAAM,MAAM,GAAmB,gBAAgB,CAAC,MAAwB,CAAC;YACzE,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO;SACV;AACD,QAAA,IAAI,EAAE,CAAC;AACX,KAAC,CAAC;AACN;;;;"}
@@ -1,3 +1,3 @@
1
- import { RequestError } from '@donmahallem/turbo';
2
- import { DefinedError } from 'ajv';
3
- export declare const convertValidationError: (error: DefinedError) => RequestError;
1
+ import { RequestError } from '@donmahallem/turbo';
2
+ import { DefinedError } from 'ajv';
3
+ export declare const convertValidationError: (error: DefinedError) => RequestError;
@@ -1 +1 @@
1
- export { validateRequest } from './validate-request';
1
+ export { validateRequest } from './validate-request';
@@ -1,14 +1,13 @@
1
- import Ajv, { JSONSchemaType } from 'ajv';
2
- import { RequestHandler } from 'express';
3
- type CheckKeys = 'query' | 'params' | 'body';
4
- type MethodSignature = <T = object>(key: CheckKeys, schema: JSONSchemaType<T>, ajvInstance?: Ajv) => RequestHandler;
5
- /**
6
- * Checks a request against the given schema
7
- *
8
- * @param {string} key property of the request to check the schema against
9
- * @param {JSONSchemaType} schema the jsonschema
10
- * @param {Ajv} ajvInstance optional ajv to be used
11
- * @returns {RequestHandler} express middleware
12
- */
13
- export declare const validateRequest: MethodSignature;
14
- export {};
1
+ import Ajv, { JSONSchemaType } from 'ajv';
2
+ import { RequestHandler } from 'express';
3
+ type CheckKeys = 'query' | 'params' | 'body';
4
+ type MethodSignature = <T = object>(key: CheckKeys, schema: JSONSchemaType<T>, ajvInstance?: Ajv) => RequestHandler;
5
+ /**
6
+ * Checks a request against the given schema
7
+ * @param {string} key property of the request to check the schema against
8
+ * @param {JSONSchemaType} schema the jsonschema
9
+ * @param {Ajv} ajvInstance optional ajv to be used
10
+ * @returns {RequestHandler} express middleware
11
+ */
12
+ export declare const validateRequest: MethodSignature;
13
+ export {};
package/package.json CHANGED
@@ -1,24 +1,29 @@
1
1
  {
2
2
  "name": "@donmahallem/turbo-validate-request",
3
- "version": "0.4.4",
3
+ "version": "0.4.7",
4
4
  "description": "Turbo Helpers for express.js",
5
5
  "main": "./dist/cjs/index.cjs",
6
6
  "types": "./dist/types/index.d.ts",
7
- "module": "./dist/esm/index.mjs",
8
7
  "private": false,
8
+ "type": "module",
9
+ "exports": {
10
+ "require": "./dist/cjs/index.cjs",
11
+ "import": "./dist/esm/index.mjs",
12
+ "types": "./dist/types/index.d.ts"
13
+ },
9
14
  "keywords": [
10
15
  "express",
11
16
  "helpers"
12
17
  ],
13
18
  "typedocMain": "./src/index.ts",
14
19
  "scripts": {
15
- "build": "rollup -c rollup.config.js",
20
+ "build": "rollup -c rollup.config.mjs",
16
21
  "build:readme": "npx @appnest/readme generate --input ../package_readme_blueprint.md --config readme_config.json",
17
22
  "test": "mocha --config ../../.mocharc.json",
18
23
  "test:coverage": "c8 --config ../../.nycrc.json npm run test",
19
- "lint": "eslint -c ./.eslintrc.js --ext .ts ./src",
24
+ "lint": "eslint -c ./.eslintrc.cjs --ext .ts ./src",
20
25
  "postlint": "prettier --config ./../../.prettierrc src/**/*.ts --check",
21
- "lint:fix": "eslint -c ./.eslintrc.js --ext .ts ./src --fix",
26
+ "lint:fix": "eslint -c ./.eslintrc.cjs --ext .ts ./src --fix",
22
27
  "postlint:fix": "prettier --config ./../../.prettierrc src/**/*.ts --write",
23
28
  "prepublishOnly": "npm run test && npm run build",
24
29
  "version": "npm run build:readme && git add README.md"
@@ -49,18 +54,18 @@
49
54
  "access": "public"
50
55
  },
51
56
  "devDependencies": {
52
- "@types/express": "4.17.14",
53
- "@types/supertest": "2.0.12",
54
- "ajv": "8.11.2",
57
+ "@types/express": "4.17.21",
58
+ "@types/supertest": "2.0.16",
59
+ "ajv": "8.12.0",
55
60
  "express": "4.18.2",
56
- "supertest": "6.3.1"
61
+ "supertest": "6.3.3"
57
62
  },
58
63
  "peerDependencies": {
59
64
  "ajv": "^8.0.0",
60
65
  "express": "^4.17.1"
61
66
  },
62
67
  "dependencies": {
63
- "@donmahallem/turbo": "^2.4.4"
68
+ "@donmahallem/turbo": "^2.4.7"
64
69
  },
65
- "gitHead": "400bcfdd8470dc9d32f33c818ea7f6f89db70abb"
70
+ "gitHead": "fe9c8d328e854d0e7edb98246c816ed5a9af71dc"
66
71
  }
@@ -6,6 +6,7 @@
6
6
  import { RequestError } from '@donmahallem/turbo';
7
7
  import { DefinedError } from 'ajv';
8
8
 
9
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
9
10
  export const convertValidationError: (error: DefinedError) => RequestError = (error: DefinedError): RequestError => {
10
11
  const errorPath: string = error.instancePath === '' ? 'root' : error.instancePath;
11
12
  switch (error.keyword) {
@@ -11,7 +11,6 @@ type CheckKeys = 'query' | 'params' | 'body';
11
11
  type MethodSignature = <T = object>(key: CheckKeys, schema: JSONSchemaType<T>, ajvInstance?: Ajv) => RequestHandler;
12
12
  /**
13
13
  * Checks a request against the given schema
14
- *
15
14
  * @param {string} key property of the request to check the schema against
16
15
  * @param {JSONSchemaType} schema the jsonschema
17
16
  * @param {Ajv} ajvInstance optional ajv to be used