feat: 增强功能批量入库 - 双色彩引擎/抖动/杂色清理/品牌色板/PDF导出/编辑工具/分享/i18n 等验收代码
This commit is contained in:
1 parent
02762400fb
commit
f846fabfc6
77 files changed
+11372
-226
No files matched your search
@@ -4,6 +4,7 @@ import type Database from "better-sqlite3";
|
||||
import { getDb } from "../db/index.js";
|
||||
import { generateChibiImage, ChibiError, type GenerateRequest } from "./generate.js";
|
||||
import { findTemplate, type ChibiCategory, type Composition } from "./prompts.js";
|
||||
import { createRateLimiter, RATE_LIMITS } from "../security/rate-limit.js";
|
||||
|
||||
const CATEGORIES: readonly ChibiCategory[] = ["landscape", "person", "pet", "object", "food"];
|
||||
const COMPOSITIONS: readonly Composition[] = ["主体特写", "半幅构图", "完整构图"];
|
||||
@@ -28,7 +29,10 @@ function resolveDb(injected?: Database.Database): Database.Database {
|
||||
export function createChibiRouter(injectedDb?: Database.Database): Router {
|
||||
const router = Router();
|
||||
|
||||
router.post("/generate", async (req: Request, res: Response): Promise<void> => {
|
||||
// 防刷限流:AI 生成 10 次/小时/IP(每路由实例独立计数,测试互不干扰)
|
||||
const chibiLimiter = createRateLimiter(RATE_LIMITS.chibiGenerate)("chibi_generate");
|
||||
|
||||
router.post("/generate", chibiLimiter, async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const body = (req.body ?? {}) as Record<string, unknown>;
|
||||
|
||||
|
||||
Reference in new issue
Block a user