Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 1x 1x 1x 1x 1x 1x 2x 2x 2x 1x 1x 1x 1x | import express from 'express';
import {UserService} from '@models';
import {BadRequestError} from '@errors';
import {asyncWrapper} from '@util/async-wrapper';
const router: express.Router = express.Router();
/**
* Controller to handle getting the profile picture of a specific user
* @param req - Request
* @param res - Response
* @param _next - Unused next
*/
export const userProfilePicController: express.RequestHandler =
async (req, res, _next) => {
const userId = Number.parseInt(req.params.userId, 10);
Iif (isNaN(userId) || typeof req.user !== 'object') {
throw new BadRequestError('Missing fields');
}
const pb = await UserService.getProfilePicture(req.user, userId);
res.type('image/jpeg');
res.send(pb.data);
};
/**
* Add the routers to the route
*/
router.get('/:userId/profile-pic', asyncWrapper(userProfilePicController));
export default router;
|