feat: GET /api/articles/admin — all articles with status for admin panel
This commit is contained in:
@@ -50,6 +50,22 @@ router.post('/generate', async (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
// GET /api/articles/admin — все статьи для админки (включая черновики, все поля)
|
||||
router.get('/admin', async (req, res) => {
|
||||
try {
|
||||
const { query } = require('../config/db');
|
||||
const limit = Math.min(parseInt(req.query.limit) || 100, 200);
|
||||
const offset = parseInt(req.query.offset) || 0;
|
||||
const { rows } = await query(
|
||||
`SELECT id, slug, title, excerpt, cover_url, tags, author, reading_time,
|
||||
status, seo_title, seo_descr, views, published_at, created_at, updated_at
|
||||
FROM articles ORDER BY created_at DESC LIMIT $1 OFFSET $2`,
|
||||
[limit, offset]
|
||||
);
|
||||
res.json(rows);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
// GET /api/articles/id/:id — одна статья по числовому id
|
||||
router.get('/id/:id', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user