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

apicco-lib

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apicco-lib - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

build.js

@@ -22,2 +22,3 @@ const path = require('path');

joiOptions = {},
errorCode = 422,
verbose = false

@@ -67,2 +68,3 @@ } = {}) {

joi,
errorCode,
schema: validate,

@@ -69,0 +71,0 @@ options: joiOptions

2

package.json
{
"name": "apicco-lib",
"version": "1.1.0",
"version": "1.1.1",
"description": "",

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

@@ -22,3 +22,5 @@ const Boom = require('boom');

function validate({ schema = {}, options = {}, joi } = {}) {
function validate({
schema = {}, options = {}, errorCode = 422, joi
} = {}) {
return (ctx, next) => {

@@ -31,5 +33,12 @@ const opts = merge({}, { abortEarly: false }, options);

if (!isEmpty(error)) {
throw Boom.badData('', {
details: buildErrorDetails(error.details)
});
switch (errorCode) {
case 400:
throw Boom.badRequest('', {
details: buildErrorDetails(error.details)
});
default:
throw Boom.badData('', {
details: buildErrorDetails(error.details)
});
}
}

@@ -36,0 +45,0 @@ }

@@ -40,2 +40,19 @@ /* eslint-env jest */

});
test('throws a 400 boom error when configured as such', async () => {
const ctx = mockCtx();
const next = jest.fn();
const schema = { foo: Joi.required() };
try {
await validate({
schema,
errorCode: 400,
joi: Joi
})(ctx, next);
} catch (err) {
expect(err.isBoom).toBeTruthy();
expect(err.output.statusCode).toBe(400);
}
});
});

@@ -42,0 +59,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