Restored to '3905f52571b4fa7e048e16d7a3b94ee66307d072'
Replit-Restored-To: 3905f52571
This commit is contained in:
@@ -86,6 +86,19 @@ export async function registerRoutes(
|
||||
});
|
||||
|
||||
app.get("/api/articles/category/:category", async (req, res) => {
|
||||
const page = parseInt(req.query.page as string);
|
||||
const limit = parseInt(req.query.limit as string) || 12;
|
||||
if (page && page > 0) {
|
||||
const result = await storage.getArticlesByCategoryPaginated(req.params.category, page, limit);
|
||||
const totalPages = Math.ceil(result.total / limit);
|
||||
return res.json({
|
||||
articles: result.articles,
|
||||
total: result.total,
|
||||
page,
|
||||
totalPages,
|
||||
hasMore: page < totalPages,
|
||||
});
|
||||
}
|
||||
const articles = await storage.getArticlesByCategory(req.params.category);
|
||||
res.json(articles);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user