New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@janiscommerce/api

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janiscommerce/api - npm Package Compare versions

Comparing version 5.0.1 to 5.1.0

lib/error-with-variables.js

5

CHANGELOG.md

@@ -9,2 +9,7 @@ # Changelog

## [5.1.0] - 2020-06-23
### Added
- Added support for error response with messageVariables
- Added new `ErrorWithVariables` to easily send a response with variables
## [5.0.1] - 2020-06-18

@@ -11,0 +16,0 @@ ### Removed

8

lib/dispatcher.js

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

this.setResponseError(message, code);
this.setResponseError(message, code, err.messageVariables);
}

@@ -227,7 +227,7 @@ }

this.setResponseError(message, code);
this.setResponseError(message, code, err.messageVariables);
}
}
setResponseError(message, httpCode) {
setResponseError(message, httpCode, messageVariables) {
this.hasError = true;

@@ -239,3 +239,3 @@

this.api
.setBody({ message });
.setBody({ message, messageVariables });
}

@@ -242,0 +242,0 @@

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

const APIError = require('./error');
const ErrorWithVariables = require('./error-with-variables');

@@ -11,3 +12,4 @@ module.exports = {

Dispatcher,
APIError
APIError,
ErrorWithVariables
};
{
"name": "@janiscommerce/api",
"version": "5.0.1",
"version": "5.1.0",
"description": "A package for managing API from any origin",

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

@@ -122,2 +122,16 @@ # api

## ErrorWithVariables
This is an error class to use to return easily a message and variables apply to it, for example to handle error translation properly.
Every variable should be a scalar (not an array or object). Otherwise it will be casted to a string.
```js
const { ErrorWithVariables } = require('@janiscommerce/api');
throw new ErrorWithVariables('some.error.to.translate', {
name: 'Some name to replace in translation'
})
```
## Session injection

@@ -124,0 +138,0 @@ *Since 2.0.0*

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