Skip to content

Commit 7ef7b3e

Browse files
committed
fix some errors
1 parent a270d67 commit 7ef7b3e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const express = require("express");
22
const mongoose = require("mongoose");
33
const cors = require("cors");
4+
const { errors } = require("celebrate");
45
const mainRouter = require("./routes/index");
56
const { createUser, login } = require("./controllers/users");
67
const { getClothingItem } = require("./controllers/clothingItems");
@@ -10,7 +11,6 @@ const {
1011
validateUserBody,
1112
validateUserLogIn,
1213
} = require("./middlewares/validation");
13-
const { errors } = require("celebrate");
1414
const { requestLogger, errorLogger } = require("./middlewares/logger");
1515

1616
const app = express();
@@ -32,7 +32,7 @@ app.use("/", mainRouter);
3232

3333
app.use(errorLogger);
3434

35-
//celebrate error handler
35+
// celebrate error handler
3636
app.use(errors());
3737
// centralized handler
3838
app.use(errorHandler);

controllers/users.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ const createUser = (req, res, next) => {
4545
const { name, avatar, email, password } = req.body;
4646

4747
if (!email) {
48-
return res
49-
.status(invalidDataError)
50-
.send({ message: "Email or Password is required!" });
48+
next(new BadRequestError("Email or Password is required!"));
49+
// return res
50+
// .status(invalidDataError)
51+
// .send({ message: "Email or Password is required!" });
5152
}
5253

5354
return User.findOne({ email })

0 commit comments

Comments
 (0)