forked from admin/zeropost-engine
feat: SMTP, maintenance mode, blog topic bank UI
8. SMTP: emailService.js (nodemailer), templates (welcome/payment/low_credits) /api/admin/email/test — тест отправки app_settings category=smtp (HOST/PORT/USER/PASS/FROM/ENABLED) 9. Maintenance mode: middleware в index.js, MAINTENANCE_MODE в engine settings При true → 503 для всех запросов кроме /uploads и /api/settings 10. Blog topic bank: DB: blog_topics(category,topic,is_used,source,priority) 40 тем мигрированы из хардкода (source=hardcoded) autogen.js: getNextTopic берёт из DB, fallback на TOPIC_BANK admin API: GET/POST /blog-topics, DELETE /:id, POST /generate (AI +10)
This commit is contained in:
@@ -29,6 +29,20 @@ require('./src/services/metricsCollector').startAutoCollect();
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
// ── Maintenance mode middleware ──────────────────────────────
|
||||
app.use((req, res, next) => {
|
||||
// Пропускаем статику и admin endpoints (чтобы можно было отключить режим)
|
||||
if (req.path.startsWith('/uploads') || req.path.startsWith('/api/settings')) return next();
|
||||
const settings = require('./src/services/settings');
|
||||
settings.get('MAINTENANCE_MODE', 'false').then(val => {
|
||||
if (val === 'true' && !req.headers['x-internal-secret']) {
|
||||
settings.get('MAINTENANCE_MESSAGE', 'Ведутся технические работы').then(msg => {
|
||||
res.status(503).json({ error: msg, code: 'MAINTENANCE' });
|
||||
});
|
||||
} else next();
|
||||
}).catch(() => next());
|
||||
});
|
||||
|
||||
// Раздача загруженных файлов (обложки статей и т.п.)
|
||||
const path = require('path');
|
||||
const UPLOADS_DIR = process.env.UPLOADS_DIR || '/var/www/zeropost-uploads';
|
||||
|
||||
Reference in New Issue
Block a user