新增内容判断引擎文章发布接口
This commit is contained in:
@@ -10,6 +10,7 @@ import crypto from 'crypto';
|
||||
import PDFDocument from 'pdfkit';
|
||||
import { initDB, getDB, UPLOAD_DIR } from './db.js';
|
||||
import { signToken, verifyToken, authMiddleware } from './middleware/auth.js';
|
||||
import { createContentIngestRouter } from './content-ingest.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const app = express();
|
||||
@@ -124,6 +125,7 @@ function rateLimit({ windowMs = 60_000, max = 30 } = {}) {
|
||||
}
|
||||
const publicRateLimit = rateLimit({ windowMs: 60_000, max: 60 });
|
||||
app.use('/api/diagnosis', publicRateLimit);
|
||||
app.use('/api/internal/content/v1', createContentIngestRouter());
|
||||
|
||||
app.post('/api/contact/leads', (req, res) => {
|
||||
const { name, company = '', phone, need = '' } = req.body || {};
|
||||
@@ -556,6 +558,12 @@ app.get('/api/cms/contact-leads', (req,res)=>{
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
if (res.headersSent) return next(err);
|
||||
if (err?.type === 'entity.too.large') {
|
||||
if (req.path.startsWith('/api/internal/content/v1/')) {
|
||||
return res.status(413).json({ success: false, error: { code: 'CONTENT_TOO_LARGE', message: '请求体超过长度限制', retryable: false } });
|
||||
}
|
||||
return res.status(413).json({ code: 413, msg: '请求体超过长度限制' });
|
||||
}
|
||||
if (err?.message?.includes('仅支持') || err?.code === 'LIMIT_FILE_SIZE' || err?.code === 'LIMIT_FILE_COUNT') {
|
||||
return res.status(400).json({ code: 400, msg: err.message || '上传文件不符合要求' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user