企业级重构:四层模块化架构 + RBAC授权 + 安全加固 + 颜色引擎/配方推演增强
架构 - 后端从 flat routes/ 重构为 modules/<domain>/ 模块化结构(8个模块) - 四层架构:Route -> Service -> Repository -> Prisma - 新增 shared/ 基础设施(AppError 异常体系、ALS 上下文、prom-client 指标) - 前端 Toast/Skeleton/Alert 组件基建 + formulaService 模板 安全 - JWT 签名算法修复(HS256 用 createHmac 而非 createHash) - 密码哈希 async scrypt + timingSafeEqual - API Key 从 localStorage 迁移至服务端 runtime/config.json - Helmet 安全头 + rate-limit 全局限流 100 req/min - 全局 auth preHandler + RBAC + Ownership 中间件 颜色引擎 - 色匹配切换为 cube 粗筛 + CIEDE2000 精排 - PantoneColor 表 + 种子数据 + 搜索端点 - AI 配色 Prompt 注入成分库 colorant 列表 配方推演 - 本地优化引擎(同 category 替换 + 成本排序) - baseFormulaId 支持 + Pareto 散点图 文档 - ADR-0003 四层架构、ADR-0004 RBAC 授权模型 - 更新 ADR-0001/0002 - api-reference.md(29端点)、project-overview.md 部署 - Dockerfile * 2 + nginx.conf + docker-compose.prod.yml - 健康探针 + 优雅关闭 + pg_dump 备份脚本 - ESLint + Prettier + tsconfig strict
This commit is contained in:
34
frontend/scripts/generate-types.ts
Normal file
34
frontend/scripts/generate-types.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { execSync } from 'child_process'
|
||||
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
const ROOT = join(import.meta.dirname, '..')
|
||||
const BACKEND = join(ROOT, '..', 'backend')
|
||||
const SPEC_FILE = join(BACKEND, 'generated', 'openapi.json')
|
||||
const OUT_DIR = join(ROOT, 'src', 'generated')
|
||||
const OUT_FILE = join(OUT_DIR, 'api.ts')
|
||||
|
||||
async function main() {
|
||||
if (!existsSync(SPEC_FILE)) {
|
||||
console.log('Generating OpenAPI spec from backend...')
|
||||
execSync('pnpm api:gen', { cwd: BACKEND, stdio: 'inherit' })
|
||||
}
|
||||
|
||||
console.log('Generating TypeScript types from OpenAPI spec...')
|
||||
const spec = JSON.parse(readFileSync(SPEC_FILE, 'utf-8'))
|
||||
|
||||
const openapiTS = await import('openapi-typescript')
|
||||
const types = await openapiTS.default(new URL(`file://${SPEC_FILE}`), {
|
||||
exportType: true,
|
||||
})
|
||||
|
||||
if (!existsSync(OUT_DIR)) mkdirSync(OUT_DIR, { recursive: true })
|
||||
writeFileSync(OUT_FILE, types)
|
||||
|
||||
console.log(`Types written to src/generated/api.ts (${types.length} bytes)`)
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user