From dfe53e211484724b25a7b292cd457deee18d8182 Mon Sep 17 00:00:00 2001 From: Zakhar Molchanov Date: Sun, 23 Jun 2024 16:37:02 +0500 Subject: [PATCH] fix(backend): fixing problem with route --- .../src/controllers/UserUpdateController.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/src/controllers/UserUpdateController.ts b/backend/src/controllers/UserUpdateController.ts index fdba686..50bec8f 100644 --- a/backend/src/controllers/UserUpdateController.ts +++ b/backend/src/controllers/UserUpdateController.ts @@ -1,13 +1,21 @@ -import { Request, Response } from "express"; -import { validationResult } from "express-validator"; +import { Request, Response, NextFunction } from "express"; +import { validationResult, ValidationChain } from "express-validator"; import { User } from "../entity/User"; import { AppDataSource } from "../db"; import { userValidationDescription } from "../middlewares/validation"; import { verifyToken } from "../middlewares/verifyToken"; -export const UserControllerUpdate = [ +export const UserControllerUpdate: [ + (req: Request, res: Response, next: NextFunction) => void, + ...ValidationChain[], + ( + req: Request, + res: Response, + next: NextFunction, + ) => Promise | void>, +] = [ verifyToken, - userValidationDescription(), + ...userValidationDescription(), async (req: Request, res: Response) => { try { @@ -18,7 +26,9 @@ export const UserControllerUpdate = [ const login = req.user?.login; if (!login) { - return res.status(403).json({ message: "Не удалось идентифицировать пользователя" }); + return res + .status(403) + .json({ message: "Не удалось идентифицировать пользователя" }); } const userRepository = AppDataSource.getRepository(User);