diff --git a/src/controllers/auth.js b/src/controllers/auth.js index 95b078f..bc94b22 100644 --- a/src/controllers/auth.js +++ b/src/controllers/auth.js @@ -27,7 +27,7 @@ export const signupController = async (req, res) => { const { email } = req.body; const user = await findUser({ email }); if (user) { - throw createHttpError(409, 'Email in use'); + throw createHttpError(409, 'Email in use!'); } const newUser = await signup(req.body); diff --git a/src/middlewares/errorHandler.js b/src/middlewares/errorHandler.js index c3dfe30..5d71b76 100644 --- a/src/middlewares/errorHandler.js +++ b/src/middlewares/errorHandler.js @@ -5,13 +5,12 @@ export const errorHandler = (err, req, res, next) => { res.status(err.status).json({ status: err.status, message: err.name, - data: err.message, + data: { message: err.message }, }); } res.status(500).json({ status: 500, - message: 'Something went wrong', - data: err.message, + data: { message: 'Something went wrong' }, }); }; diff --git a/src/middlewares/notFoundHandler.js b/src/middlewares/notFoundHandler.js index 9d0184d..66709bd 100644 --- a/src/middlewares/notFoundHandler.js +++ b/src/middlewares/notFoundHandler.js @@ -1,6 +1,6 @@ export const notFoundHandler = (req, res) => { res.status(404).json({ status: 404, - message: 'Not found', + data: { message: 'Not found' }, }); };