added endpoint for retrieving users' posts, updated userShouldExist middleware to account userId param.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user