fix: enrich-batch Endpoint in words-Router verschieben (war nach 404-Handler in index.js)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-18 21:03:20 +02:00
parent 7ba6b7120b
commit 294608de22
2 changed files with 14 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
const router = require('express').Router();
const { query } = require('../db');
const { runEnrichTick, enrichWordsSync } = require('../lib/enrichWords');
const STATUSES = ['requested', 'translated', 'generated', 'blocked', 'published'];
@@ -9,6 +10,18 @@ const STATUS_TIMESTAMP = {
blocked: 'blocked_at',
};
// POST /api/words/enrich-batch — manueller Trigger für Wort-Anreicherung
router.post('/enrich-batch', async (req, res, next) => {
try {
const sync = req.query.sync === 'true';
if (sync) {
const max = parseInt(req.query.max) || 500;
return res.json(await enrichWordsSync({ max }));
}
res.json(await runEnrichTick());
} catch (err) { next(err); }
});
// GET /api/words
router.get('/', async (req, res, next) => {
try {