Socket
Socket
Sign inDemoInstall

q3-core-composer

Package Overview
Dependencies
Maintainers
1
Versions
286
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

q3-core-composer - npm Package Compare versions

Comparing version 1.0.13 to 1.0.20

8

index.js

@@ -6,3 +6,6 @@ const connect = require('connect');

const effect = require('./lib/effect');
const validate = require('./lib/validate');
const {
validateBody,
validateIf,
} = require('./lib/validate');

@@ -40,3 +43,3 @@ const {

flatten([
flatten(ctr.validation, [validate]),
flatten(ctr.validation, [validateBody]),
flatten(ctr.authorization, [

@@ -58,2 +61,3 @@ verify,

check,
validateIf,
};

@@ -16,2 +16,4 @@ const { get, set } = require('lodash');

// this needs refactoring
// needs conditional?
const redact = (modelName) => {

@@ -76,4 +78,4 @@ const locations = {

const verify = ({ user }, res, next) => {
if (!user) {
const verify = ({ user, passedGrants }, res, next) => {
if (!user && !passedGrants) {
res.status(401).send();

@@ -80,0 +82,0 @@ } else {

const {
matchedData,
validationResult,
checkSchema,
} = require('express-validator');

@@ -9,3 +10,22 @@ const { pickBy } = require('lodash');

module.exports = (req, res, next) => {
const validateIf = (
discriminatorKey = '__t',
schemas = {},
) => async (req, res, next) => {
const v = req.body[discriminatorKey];
const schema = schemas[v || 'base'];
if (schema) {
await Promise.all(
checkSchema(schema).map((e) => e.run(req)),
);
next();
} else {
next(
new Error(req.t('messages:discriminatorRequired')),
);
}
};
const validateBody = (req, res, next) => {
try {

@@ -23,1 +43,6 @@ validationResult(req).throw();

};
module.exports = {
validateBody,
validateIf,
};
{
"name": "q3-core-composer",
"version": "1.0.13",
"version": "1.0.20",
"main": "index.js",

@@ -10,14 +10,15 @@ "jest": {

"connect": "^3.7.0",
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"express-mung": "^0.5.1",
"express-validator": "^6.2.0",
"flat": "^4.1.0",
"flat": "5.0.0",
"lodash": "^4.17.15",
"micromatch": "^4.0.2"
"micromatch": "^4.0.2",
"mongoose": "^5.7.7"
},
"devDependencies": {
"express": "^4.17.1",
"supertest": "^4.0.2"
},
"gitHead": "824e526a638198a3d3ddbd7d077bdf676f876711"
"gitHead": "0b3cd9783303e9853037b7bdacdaffbc549f4ad2"
}

@@ -1,2 +0,2 @@

const validate = require('../lib/validate');
const { validateBody } = require('../lib/validate');

@@ -14,3 +14,3 @@ const req = { body: {} };

req.body = null;
validate(req, res, next);
validateBody(req, res, next);
expect(next).toHaveBeenCalledWith(expect.any(Object));

@@ -28,3 +28,3 @@ });

validate(req, res, next);
validateBody(req, res, next);
expect(req.body).not.toHaveProperty('dropNull');

@@ -31,0 +31,0 @@ expect(req.body).not.toHaveProperty('dropUndefined');

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