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.2.8 to 1.3.0

20

build.js

@@ -77,17 +77,13 @@ const path = require('path');

for (const param in validate) {
if (!validate.hasOwnProperty(param)) {
continue;
}
let joiSchema = validate;
if (!joiSchema.isJoi) {
joiSchema = joi.object(validate);
}
const { isJoi = true, _flags = {} } = validate[param];
const validateParams = joiSchema.describe().children;
for (const param in validateParams) {
const { flags = {} } = validateParams[param];
if (!isJoi) {
throw new Error(
`Invalid Joi validation for ${actionName} action: ${param}.`
);
}
const paramsName = flags.presence === 'required' ? `*${param}` : param;
const paramsName = _flags.presence === 'required' ? `*${param}` : param;
params.push(paramsName);

@@ -94,0 +90,0 @@ }

51

build.test.js

@@ -20,3 +20,3 @@ /* eslint-env jest */

beforeAll(() => {
jest.mock('require-directory', () => jest.fn(() => {
this.mockedDirectory = jest.fn(() => {
const Joi = require('joi');

@@ -47,3 +47,5 @@

};
}));
});
jest.mock('require-directory', () => this.mockedDirectory);
});

@@ -92,2 +94,47 @@

test('supports returning Joi.object in validation', async () => {
const ctx = mockCtx({
method: 'GET',
path: '/api/v1/discovery'
});
const next = jest.fn();
this.mockedDirectory = jest.fn(() => {
const Joi = require('joi');
return {
movies: {
list: {
validate: {},
handle: () => {}
},
play: {
validate: {
title: Joi.string().required()
},
handle: () => {}
}
},
books: {
read: {
validate: Joi.object({
title: Joi.string().required(),
author: Joi.string()
}),
handle: () => {}
}
}
};
});
await buildAPI()(ctx, next);
expect(ctx._matchedRoute).toBe('/api/v1/discovery');
expect(ctx.body).toEqual({
'books.read': expect.arrayContaining(['*title', 'author']),
'movies.list': [],
'movies.play': expect.arrayContaining(['*title'])
});
});
test('assigns koa-router to returned apicco middleware', async () => {

@@ -94,0 +141,0 @@ const middleware = buildAPI();

{
"name": "apicco-lib",
"version": "1.2.8",
"version": "1.3.0",
"description": "",

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

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