14 lines
445 B
TypeScript
14 lines
445 B
TypeScript
import { Request, Response } from 'express';
|
|
import { AppError } from '../errors/app-error';
|
|
import { listerMesEmpruntsEnCours } from '../services/emprunt.service';
|
|
|
|
export async function getMesEmprunts(req: Request, res: Response): Promise<void> {
|
|
const user = req.user;
|
|
if (!user) {
|
|
throw new AppError(401, 'Authentification requise');
|
|
}
|
|
|
|
const emprunts = await listerMesEmpruntsEnCours(user.id);
|
|
res.json({ data: emprunts });
|
|
}
|