Skip to content

修复逻辑问题 - #189

Merged
yourtion merged 3 commits into
mainfrom
fix/v3.0.1-docfix
Jun 28, 2026
Merged

修复逻辑问题#189
yourtion merged 3 commits into
mainfrom
fix/v3.0.1-docfix

Conversation

@yourtion

Copy link
Copy Markdown
Owner

No description provided.

yourtion added 3 commits June 28, 2026 14:33
修复 v3.0.0 发布后发现的问题,无运行时 breaking change。

P1 发布缺陷(阻塞):子包 peerDependencies.erest 带未替换的 workspace:^,
npm install 报 EUNSUPPORTEDPROTOCOL。新增 scripts/publish.mjs:发布前把
workspace 协议替换为实际版本号,publish 后还原(已实测打包 manifest 验证)。
发布命令改为 npm run publish:all。

P2/P7 文档签名:README 三框架接入示例用了错误的 handler 签名(Express
(req,res)、Koa ctx.body=、leizmweb ctx.response.json)。实际所有框架下
register/define handler 均为标准化 (ctx,next),响应统一走 ctx.reply。
README 改为主推 registerTyped 的 (req,reply) 框架无关签名。

P3 文档生成方法名:api.docs.generateDocs 不存在,正确入口是 genDocs(savePath)
+ 构造时 docs 配置开关。

P4 version 类型:IApiOptionInfo.version 从 Date 改为 string。

P5 Express 5:peer dep 从 ^4.0.0 扩展为 ^4||^5,5 为推荐版本;补 app 级
错误中间件说明(Express 5 改变了子 router 错误传播语义)。

P6 basePath:补充说明仅用于文档生成,不作为路由前缀。

P8/P9/P11/P12:移除 tsconfig baseUrl、补 @types/node 与 tsconfig 示例、
body-parser extended 说明、@koa/router 替代说明。

新增 publish:all / publish:all:dry 脚本入口;核心+三 adapter bump 到 3.0.1
(@erest/gen 为独立实验包不动)。MIGRATION.md 补充 3.0.1 章节。

测试:核心库 266 + examples 13 共 279 测试全过,无回归。Express 5 经独立
脚本验证 GET/POST/校验/错误传递均正常。
koa-router 整包已停止维护并标记 deprecated(npm 安装 warning)。
@koa/router 是官方继任包,API 与 koa-router 完全一致——实测
@koa/router@15 + koa@3.2 + erest 全功能正常(GET/POST/校验/错误传递、
forceGroup 的 new Router({prefix}) 构造路径)。

@erest/koa peer dep 扩展为同时声明二者并标记 optional:
  koa-router: ^13.0.0  (optional, 旧)
  @koa/router: ^13.0.0 (optional, 新,推荐)
用户装任一路由库均无 missing peer warning。已验证打包 manifest 正确。

README Koa 章节主推 @koa/router;MIGRATION.md 补充第 7 节说明。

Koa 本体无需处理:^3.0.0 peer 已覆盖最新 3.2.1,3.x 向后兼容。
仓库测试仍用 koa-router(devDep 不变,开发环境 deprecated warning 无害)。

测试:279 全过,无回归。
仓库 devDep 与测试套件升级到 Express 5.2.1,测试直接跑在 Express 5 上。

发现并修复一个真实的 Express 5 兼容 bug:
Express 5 对未匹配的 content-type(如 multipart/form-data)不再初始化
req.body = {},而是保持 undefined(Express 4 会初始化为 {})。erest 的
compileValidate 对 body === undefined 会跳过 body 校验,导致 Express 5 下
带 multipart 上传、又定义了 body schema 的接口,body 校验被静默跳过
(缺字段不报错)。修复:Express adapter 构造 Context 时把 req.body ?? {}
归一化为 {},恢复 Express 4 行为,保留 params.ts 核心契约不变。

test-test.ts 错误中间件从 router 级改为 app 级(适配 Express 5 子 router
错误传播语义变化,README 已同步说明)。

同时纠正发布方案:
- 移除多余的 scripts/publish.mjs(基于错误结论:误用 npm pack 验证,
  实测 pnpm 9 的 pnpm publish -r 能正确替换所有依赖类型含 peerDependencies
  的 workspace 协议)
- 发布命令改为 npm run publish:all(= pnpm publish -r --no-git-checks),
  由 prepublishOnly 钩子保证 format + 全量测试

测试:279 全过(266 核心 + 13 examples),全部跑在 Express 5.2.1。
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.59%. Comparing base (198f837) to head (46fea4a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #189   +/-   ##
=======================================
  Coverage   91.59%   91.59%           
=======================================
  Files          28       28           
  Lines        2821     2821           
  Branches      719      719           
=======================================
  Hits         2584     2584           
  Misses        235      235           
  Partials        2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@yourtion
yourtion merged commit 7728444 into main Jun 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants