import { Router, Request, Response, NextFunction } from 'express';
import { getPublicActivity } from './activity-public.service';

const router = Router();

// GET /api/activity/public?limit=20
router.get('/public', async (req: Request, res: Response, next: NextFunction) => {
  try {
    const limit = Math.min(parseInt(req.query.limit as string) || 20, 50);
    const items = await getPublicActivity(limit);
    res.json(items);
  } catch (err) {
    next(err);
  }
});

export { router as activityPublicRouter };
