Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Upgrade validator from 13.11.0 to 13.12.0 #8

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Controller/categoryController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ exports.createCategory = catchAsync(async (req,res,next)=>{
const newCat = await Category.create(req.body);
res.status(201).json({
status:'success',
review:newCat
category:newCat
})
if(!newCat){
return next (new AppError(' Something went wrong while posting your review', 400))
return next (new AppError(' Something went wrong while creating your category', 400))
}
});

Expand Down
7 changes: 3 additions & 4 deletions Controller/recipeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ exports.top5recipe = (req, res, next)=>{
next();
}

exports.getAllRecipe =catchAsync(async (req, res, next)=>{
exports.getAllRecipe = catchAsync(async (req, res, next)=>{
try {
const features = new APIFeatures(Recipe.find(), req.query)
const features = new APIFeatures(Recipe.find().populate('category'), req.query)
.filter()
.sort()
.limitFields()
Expand Down Expand Up @@ -190,7 +190,7 @@ exports.getUserRecipes = async (req, res, next) => {
};

exports.getSingleRecipe = catchAsync(async (req, res,next)=>{
const oneRecipe= await Recipe.findById(req.params.id).populate('reviews');
const oneRecipe = await Recipe.findById(req.params.id).populate('reviews');
if(!oneRecipe){
return next (new AppError(`Provided id ${req.params.id} is not found (or doesnt exist)`, 404));
}
Expand All @@ -199,7 +199,6 @@ exports.getSingleRecipe = catchAsync(async (req, res,next)=>{
status:'Success',
recipe:oneRecipe
})


})

Expand Down
35 changes: 17 additions & 18 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ const express = require ('express');
const morgan = require('morgan');
const GlobalError = require('./utils/globalError');
const errorHandler = require('./Controller/errorController');
const rateLimit = require('express-rate-limit');
const helmet = require('helmet');
const mongoSanitize= require('express-mongo-sanitize');
const xss = require('xss-clean');
const hpp = require('hpp');
const csurf = require('csurf');
//const rateLimit = require('express-rate-limit');
//const helmet = require('helmet');
//const mongoSanitize= require('express-mongo-sanitize');
//const xss = require('xss-clean');
//const hpp = require('hpp');
//const csurf = require('csurf');

const app = express();
app.use(helmet());
//app.use(helmet());

const limiter = rateLimit({
max:100,
windowMs:60*60*1000,
message:'Too many request from this IP. Please try an hour later'
})
//const limiter = rateLimit({
// max:100,
// windowMs:60*60*1000,
// message:'Too many request from this IP. Please try an hour later'
//})

app.use('/api', limiter);
//app.use('/api', limiter);
app.use(express.json());

app.use(mongoSanitize());
app.use(xss());
app.use(csurf());
app.use(hpp());
// app.use(mongoSanitize());
// app.use(xss());
// app.use(hpp());

const userRoute = require('./Routes/userRoutes');
const recipeRoute = require('./Routes/recipeRoute');
Expand All @@ -48,4 +47,4 @@ app.all('*', (req, res, next)=>{
next(new GlobalError(`This ${req.originalUrl} link is not defined on this server`, 404));
})
app.use(errorHandler);
module.exports=app;
module.exports=app;
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"nodemailer": "^6.9.13",
"sharp": "^0.33.3",
"uuid": "^9.0.1",
"validator": "^13.11.0",
"validator": "^13.12.0",
"xss-clean": "^0.1.4"
},
"devDependencies": {
Expand Down