Repository navigation
杂项收尾:/api 未匹配返回 JSON 404、biome 升级修 CI、README 补 APP_URL、后端错误码 + 前端 i18n - #125
Merged
todosdev[bot] merged 3 commits intoOct 18, 2026
Merged
Conversation
added 3 commits
October 18, 2026 08:43
- Unmatched /api/* now returns a JSON 404 with a stable code instead of the SPA fallback (covers wrong-method hits on known routes too); added tests. - Upgrade @biomejs/biome to 2.5.15; fix the new noUnsafeOptionalChaining rule in admin stats. No mass reformatting. - Add APP_URL/APP_NAME/RP_ID/APP_ORIGIN to the .dev.vars example in both READMEs. - Add stable error codes to auth/link responses; the frontend maps known codes through i18n (en + zh-CN) and falls back to the original message otherwise. Checkpoint: xRCMbetOksxXJ9bM_fzBA
…ing tests - Add stable error codes to verify-email, forgot/reset-password, refresh and passkey-registration responses, and map the missing 2FA/link codes through i18n (en + zh-CN). - Point the README .dev.vars APP_ORIGIN at the Vite origin (:5173) so passkeys verify against the page origin. - Add routing tests asserting /api/health still 200 and OPTIONS preflight still returns CORS 204. Checkpoint: c0Po49GriX6RBspR83CqL
- Add 'tds/**' to ci.yml push branches so platform conversation-branch pushes auto-run CI; pull_request and workflow_dispatch are unchanged. - Assert workflow_run.head_branch == 'main' in deploy.yml so a non-main CI run can never trigger the production deploy. - Pin tag.yml's CI lookup to branch: 'main' so a tds/** push run at the same commit cannot satisfy the pre-tag check. Checkpoint: RJ2gyK0wguvPmlXIIjvtw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/*request (any method, including wrong-method hits on known routes) return a JSON404with a stablecode, instead of falling through to the SPA.@biomejs/biometo2.5.15(the Renovate PR's target) and fix the newly-promotednoUnsafeOptionalChainingviolations so CI passes.codefields to backend error responses and map them through frontend i18n (en + zh-CN); fill the missing required vars in the README.dev.varsexample; auto-run CI ontds/**pushes.Changes
Backend (
apps/worker)src/index.ts: add anapp.all('/api/*')catch-all returning JSON404(code: NOT_FOUND), give the error handlercode: INTERNAL_SERVER_ERROR, and exportappfor tests.src/lib/errors.ts(new):apiError(c, status, code, error)helper so every error response carries a machine-readable code alongside the originalerrormessage.src/routes/auth.ts/src/routes/links.ts: attachcodeto all error responses across login, register, 2FA, change-password and link create/edit — plus verify-email, forgot/reset-password, refresh and passkey registration.src/routes/admin.ts: fixnoUnsafeOptionalChainingwith a defensive(… | undefined)?.n ?? 0(matches the existinglinks.tsidiom).test/routing.test.ts(new): asserts JSON 404 for unknown and wrong-method/api/*,/api/healthstill 200, OPTIONS preflight still CORS 204, and error-code assertions for register/login.Frontend (
apps/web)src/api/client.ts: propagate the responsecodethroughApiRequestError.src/lib/apiErrorCodes.ts(new) +apiErrorCodes.test.ts:code → i18n keymap, cross-checked to resolve in both locales.src/lib/toast.ts:resolveApiErrorlocalizes known codes and falls back to the original message otherwise.src/i18n/locales/{en,zh-CN}.ts: newerrors.*namespace (30+ keys).toastApiErrorcall sites now passt.Build / CI / docs
biome.json$schema→2.5.15;package.json+pnpm-lock.yaml→ biome2.5.15(no other dependency changes)..github/workflows/ci.yml: push branches[main, 'tds/**']so platform branch pushes run CI..github/workflows/deploy.yml: assertworkflow_run.head_branch == 'main'(defense-in-depth so non-main CI can never deploy)..github/workflows/tag.yml: pin the pre-tag CI lookup tobranch: 'main'.README.md/README.zh-CN.md: addAPP_URL/APP_NAME/RP_ID/APP_ORIGINto the.dev.varsexample (APP_ORIGINpoints at the Vite originhttp://localhost:5173so passkeys verify against the page origin).Testing
pnpm install --frozen-lockfile,pnpm check,pnpm typecheck,pnpm build,pnpm test(worker 34 + web 28),shellcheck .github/scripts/*.sh, deploy-script tests (17),pnpm audit --prod --audit-level=high, andactionlint .github/workflows/*.ymlall pass.wrangler dev+ curl): duplicate-email register returns409 {"error":"Email or username already taken","code":"EMAIL_OR_USERNAME_TAKEN"};GET /api/does-not-existandGET /api/auth/2fa/totp/setupreturn JSON 404;/loginstill serves the SPA.