Skip to content

Commit

Permalink
fix(backend): fixing problem with route
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakharMolchanov committed Jun 23, 2024
1 parent 6d3556f commit dfe53e2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions backend/src/controllers/UserUpdateController.ts
Original file line number Diff line number Diff line change
@@ -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<Response<any> | void>,
] = [
verifyToken,
userValidationDescription(),
...userValidationDescription(),

async (req: Request, res: Response) => {
try {
Expand All @@ -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);
Expand Down

0 comments on commit dfe53e2

Please sign in to comment.