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

abl-utils

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abl-utils - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "abl-utils",
"title": "ABL - utils",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -6,0 +6,0 @@ "description": "description",

@@ -21,2 +21,20 @@ "use strict";

export function processMongoError(error, user) {
const key = error.message.match(/\$(\S+)/)[1];
return translate(`mongo.${key}`, user) || translate("mongo.E11000", user);
}
export function processStripeError(error, user) {
switch (error.type) {
case "StripeCardError":
case "StripeInvalidRequestError":
return error.message;
case "StripeAPIError":
case "StripeConnectionError":
case "StripeAuthenticationError":
default:
return translate("api.stripe-bad-request", user);
}
}
export function sendError(error, request, response, next) {

@@ -34,8 +52,13 @@ const log = debug("utils:response");

if (error.name === "MongoError" && error.code === 11000) {
const key = error.message.match(/\$(\S+)/)[1];
return send({
status: 400,
message: translate(`mongo.${key}`, request.user) || translate("mongo.E11000", request.user)
message: processMongoError(error, request.user)
});
}
if (error.type && error.type.startsWith("Stripe")) {
return send({
status: 400,
message: processStripeError(error, request.user)
});
}
if (!error.status) {

@@ -80,17 +103,5 @@ if (process.env.NODE_ENV === "production") {

.then(response.json.bind(response))
.catch(error => {
switch (error.type) {
case "StripeCardError":
case "StripeInvalidRequestError":
Object.assign(error, {status: 400});
return sendError(error, request, response);
case "StripeAPIError":
case "StripeConnectionError":
case "StripeAuthenticationError":
default:
return sendError(process.env.NODE_ENV === "production" ? makeError("api.stripe-bad-request", request.user, 400) : error, request, response);
}
})
.catch(error => sendError(error, request, response))
.done();
};
}
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