New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

celebrate

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

celebrate - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

29

lib/index.js
'use strict';
const Series = require('fastseries')({ results: true });
const Assert = require('assert');
const Insync = require('insync');
const Joi = require('joi');

@@ -19,8 +19,8 @@

return (req, res, next) => {
const validateSource = (source, callback) => {
const validateSource = (source) => {
return (req, callback) => {
const spec = schema[source];
if (!spec) {
return callback();
return callback(null);
}

@@ -33,20 +33,23 @@

}
return callback(err);
});
};
};
Insync.series([
Insync.apply(validateSource, 'headers'),
Insync.apply(validateSource, 'params'),
Insync.apply(validateSource, 'query'),
(next) => {
const validateBody = validateSource('body');
return (req, res, next) => {
Series(null, [
validateSource('headers'),
validateSource('params'),
validateSource('query'),
function (req, callback) {
const method = req.method.toLowerCase();
if (method === 'get' || method === 'head') {
return next();
return callback(null);
}
validateSource('body', next);
validateBody(req, callback);
}
], next);
], req, next);
};
};
{
"name": "celebrate",
"version": "2.1.0",
"version": "2.1.1",
"description": "A joi validation middleware for Express.",

@@ -27,3 +27,3 @@ "main": "lib/index.js",

"dependencies": {
"insync": "2.x.x"
"fastseries": "1.7.2"
},

@@ -34,6 +34,6 @@ "peerDependencies": {

"devDependencies": {
"belly-button": "2.x.x",
"belly-button": "3.x.x",
"code": "3.x.x",
"joi": "9.x.x",
"lab": "10.x.x"
"lab": "11.x.x"
},

@@ -40,0 +40,0 @@ "engines": {

@@ -14,2 +14,4 @@ ![Celebrate](https://github.com/continuationlabs/celebrate/raw/master/images/logo.png)

Wondering why *another* joi middleware library for Express? Full blog post [here](https://blog.continuation.io/time-to-clelebrate/).
## Usage

@@ -42,3 +44,3 @@

// By default, Express will try to send our errors back as HTML, if you want the JSON, add an error handler here
app.use((err, req, res) => {
app.use((err, req, res, next) => {
if (err.isJoi) {

@@ -67,3 +69,3 @@ return res.status(400).send(err);

app.get('/foo', (req, res) => { res.send('a foo request'); });
app.use((err, req, res) => {
app.use((err, req, res, next) => {
if (err.isJoi) {

@@ -98,2 +100,2 @@ return res.status(400).send(err);

*Before* opening issues on this repo, make sure your joi schema is correct and working as you intended. The bulk of this code is just exposing the joi API as Express middleware. All of the heavy lifting still happens inside joi.
*Before* opening issues on this repo, make sure your joi schema is correct and working as you intended. The bulk of this code is just exposing the joi API as Express middleware. All of the heavy lifting still happens inside joi.
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