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

express-params-checker

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-params-checker - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

27

index.js
const _ = require('lodash')
exports.has = (...requiredFields) => {
function check(para, requiredFields) {
const checkFunc = (req) => {
let params = _.extend({}, req.query, req.body, req.params)
for(let i = 0; i < requiredFields.length; i++){
if(!_.has(params, requiredFields[i])){
if(!_.has(para, requiredFields[i])){
let err = new Error(`Missing parameter: ${requiredFields[i]}`)

@@ -13,3 +12,3 @@ err.status = 400

}
req.params = params
req.para = para
}

@@ -22,1 +21,21 @@

}
exports.has = (...requiredFields) => {
let para = _.extend({}, req.query, req.body, req.params)
check(para, requiredFields)
}
exports.QueryHas = (...requiredFields) => {
let para = req.query
check(para, requiredFields)
}
exports.BodyHas = (...requiredFields) => {
let para = req.body
check(para, requiredFields)
}
exports.ParamHas = (...requiredFields) => {
let para = req.params
check(para, requiredFields)
}

2

package.json
{
"name": "express-params-checker",
"version": "1.0.0",
"version": "1.0.1",
"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