Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@janiscommerce/api-save

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janiscommerce/api-save - npm Package Compare versions

Comparing version 4.2.1 to 4.3.0

4

CHANGELOG.md

@@ -8,2 +8,6 @@ # Changelog

## [4.3.0] - 2019-12-10
### Added
- New method `postStructValidate` to add extra validation post struc validation
## [4.2.1] - 2019-11-13

@@ -10,0 +14,0 @@ ### Changed

@@ -39,2 +39,10 @@ 'use strict';

this.model = apiSaveValidator.validateModel();
if(this.postStructValidate) {
try {
await this.postStructValidate();
} catch(e) {
throw new ApiSaveError(e, ApiSaveError.codes.INVALID_REQUEST_DATA);
}
}
}

@@ -41,0 +49,0 @@

@@ -10,2 +10,3 @@ 'use strict';

INVALID_ENTITY: 2,
VALIDATION_ERROR: 3,
INTERNAL_ERROR: 99

@@ -12,0 +13,0 @@ };

2

lib/api-save-validator.js

@@ -40,3 +40,3 @@ 'use strict';

e.message = `${e.message} in ${errorPath}`;
throw new ApiSaveError(e, ApiSaveError.codes.INVALID_REQUEST_DATA);
throw new ApiSaveError(e, ApiSaveError.codes.VALIDATION_ERROR);
}

@@ -43,0 +43,0 @@ }

{
"name": "@janiscommerce/api-save",
"version": "4.2.1",
"version": "4.3.0",
"description": "A package to handle JANIS Views Save APIs",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -54,2 +54,6 @@ # API Save

postStructValidate() {
return someAsyncTask(this.dataToSave.main);
}
format({ someField, ...restoOfTheRecord }) {

@@ -99,2 +103,6 @@ return {

### postStructValidate()
This is used to validate the data received in the request, making additional validation even injecting data to the received data.
If it returns a Promise, it will be awaited.
### format(record)

@@ -101,0 +109,0 @@ You can use this to format your main record before it's saved. For example, mapping user friendly values to DB friendly values, add default values, etc.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc