From bca15027905f2759dfe976b218cbfc52a3df25be Mon Sep 17 00:00:00 2001 From: Himanshu Chhabra Date: Sun, 27 May 2018 19:33:37 +0530 Subject: [PATCH] Sending error in json to unmatched routes --- routes/api/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/routes/api/index.js b/routes/api/index.js index 1c28f24..03be1b4 100644 --- a/routes/api/index.js +++ b/routes/api/index.js @@ -23,6 +23,15 @@ router.use('/users', config.DEV_MODE ? function(req,res,next){ return res.status(500).send("could not create the user"); });}:passport.authenticate('bearer'), require('./users')); +app.get('*', (req, res) => { + res.status(404).json({ + "error": "404", + "error":{ + "message": "You are not a manager" + } + }) +}) + // config.DEV_MODE ? function (req, res, next) { // next(); // } :