added endpoint for retrieving users' posts, updated userShouldExist middleware to account userId param.

This commit is contained in:
2025-01-26 00:59:05 +03:00
parent a1890acad0
commit 84f02d3f0d
3 changed files with 14 additions and 0 deletions

View File

@@ -5,9 +5,12 @@ import { Post } from "../entity/Post";
const userShouldExist = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
const { username } = req.body;
const { userId } = req.params;
if (!(await AppDataSource.manager.findOneBy(User, {
username
})) || !(await AppDataSource.manager.findOneBy(User, {
id: Number.parseInt(userId)
}))) {
res.status(404).send("User does not exist.");
return;