-
Notifications
You must be signed in to change notification settings - Fork 8.3k
fix: 修复mock里面eventHandler重复导致无法启动 #6631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
WalkthroughReplaces a local eventHandler stub with the imported eventHandler from h3 in apps/backend-mock/api/system/dept/.post.ts. The default export continues to wrap the same async handler; internal logic and external behavior remain unchanged. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
apps/backend-mock/api/system/dept/.post.ts (1)
1-16: Ensure all mock handlers import eventHandler/defineEventHandler from h3No local
eventHandlerdefinitions were found in apps/backend-mock (no shadowing), but many mock API handlers exporteventHandlerordefineEventHandlerwithout importing it. Please add the appropriate import at the top of each:• apps/backend-mock/middleware/1.api.ts
• apps/backend-mock/routes/[...].ts
• apps/backend-mock/api/upload.ts
• apps/backend-mock/api/test.post.ts
• apps/backend-mock/api/user/info.ts
• apps/backend-mock/api/test.get.ts
• apps/backend-mock/api/status.ts
• apps/backend-mock/api/system/role/list.ts
• apps/backend-mock/api/menu/all.ts
• apps/backend-mock/api/table/list.ts
• apps/backend-mock/api/system/menu/list.ts
• apps/backend-mock/api/system/menu/path-exists.ts
• apps/backend-mock/api/system/menu/name-exists.ts
• apps/backend-mock/api/demo/bigint.ts
• apps/backend-mock/api/auth/refresh.post.ts
• apps/backend-mock/api/system/dept/[id].put.ts
• apps/backend-mock/api/system/dept/list.ts
• apps/backend-mock/api/auth/logout.post.ts
• apps/backend-mock/api/system/dept/[id].delete.ts
• apps/backend-mock/api/auth/codes.ts
• apps/backend-mock/api/auth/login.post.tsExample at file top:
import { eventHandler } from 'h3' // …or… import { defineEventHandler } from 'h3'Also verify that
h3is correctly listed under dependencies inapps/backend-mock/package.json(it currently shows"h3": "catalog:").
🧹 Nitpick comments (1)
apps/backend-mock/api/system/dept/.post.ts (1)
9-16: Optionally harden token verification to avoid 500s if jwt-utils throwsIf verifyAccessToken can throw on malformed tokens, consider guarding it so mocks consistently return 401 instead of a 500.
Apply this diff:
export default eventHandler(async (event) => { - const userinfo = verifyAccessToken(event); + let userinfo; + try { + userinfo = verifyAccessToken(event); + } catch { + return unAuthorizedResponse(event); + } if (!userinfo) { return unAuthorizedResponse(event); } await sleep(600); return useResponseSuccess(null); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/backend-mock/api/system/dept/.post.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (1)
apps/backend-mock/api/system/dept/.post.ts (1)
1-1: Good fix: use h3’s eventHandler to remove the duplicate/stub and unblock startupImporting eventHandler from h3 eliminates the local stub and the duplicate declaration issue. This aligns the mock with Nitro/H3 conventions and should resolve the startup failure.
|
非常抱歉,因为我的 pr 导致了 mock 无法正常运行,切换到上一次提交可以解决这个问题,我已经提了新的 pr 来解决这个问题 |
怎没没看见新的提交? |
已经提了,还没被合并 |
|
Description
Type of change
Please delete options that are not relevant.
pnpm-lock.yamlunless you introduce a new test example.Checklist
pnpm run docs:devcommand.pnpm test.feat:,fix:,perf:,docs:, orchore:.Summary by CodeRabbit