import express from 'express';
import { wrapAsync } from '@/api/http/request';
import * as user_progress from '@/api/controllers/user_progress.controller';

const router = express.Router();

/**
 * @openapi
 * /api/user_progress:
 *   get:
 *     tags: [User Progress]
 *     summary: List the current user's progress items
 *     responses:
 *       200:
 *         description: Progress items.
 *         content:
 *           application/json:
 *             schema: { $ref: '#/components/schemas/ListResponse' }
 *       401: { $ref: '#/components/responses/UnauthorizedError' }
 *   post:
 *     tags: [User Progress]
 *     summary: Upsert a progress item for the current user
 *     responses:
 *       200: { description: Upserted. }
 *       401: { $ref: '#/components/responses/UnauthorizedError' }
 * /api/user_progress/by-item:
 *   delete:
 *     tags: [User Progress]
 *     summary: Remove a progress item for the current user
 *     responses:
 *       200: { description: Removed. }
 *       401: { $ref: '#/components/responses/UnauthorizedError' }
 */
router.get('/', wrapAsync(user_progress.list));
router.post('/', wrapAsync(user_progress.upsert));
router.delete('/by-item', wrapAsync(user_progress.removeByItem));

export default router;
