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 | 1x 1x 5x 5x 5x 5x 5x 5x 1x | import {RequestHandler} from 'express';
import {UserService} from '@models';
const generateProfilePicController: RequestHandler = async (
req,
res,
_next,
) => {
// Extract request data from request
const username: string = req.query.username as string;
// Because of sanitization chain `query.offset`
// is not a string but either NaN or an integer
const queryOffset: number = req.query.offset as unknown as number;
// If `query.offset` was not provided user 0 as value
const offset = Number.isNaN(queryOffset) ? 0 : queryOffset;
const pb = await UserService.generateProfilePicture(req.ip, username, offset);
res.type('image/jpeg');
res.send(pb);
};
export default generateProfilePicController;
|