-
Notifications
You must be signed in to change notification settings - Fork 87
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
refactor: use egg v4 #747
base: master
Are you sure you want to change the base?
refactor: use egg v4 #747
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
BREAKING CHANGE: only support egg >= 4.0.0 the first app on egg v4 eggjs/egg#3644
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #747 +/- ##
==========================================
+ Coverage 96.33% 96.39% +0.06%
==========================================
Files 191 191
Lines 19070 19076 +6
Branches 2483 2494 +11
==========================================
+ Hits 18371 18389 +18
+ Misses 699 687 -12 ☔ View full report in Codecov by Sentry. |
typebox 也需要改造 xiekw2010/egg-typebox-validate#3 |
|
||
declare module 'egg' { | ||
export interface Context { | ||
userId?: string; |
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.
这里不是很优雅,是不是搞个 User 类然后 inject 比较好。
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.
或者 Context 可以搞成一个 Class,在项目里面可以继承覆盖框架提供的 Context。
import { Context } from 'egg';
class CNPMCoreContext extends Context {
userId: string;
init() {
this.userId = await this.fooService.getUserId();
}
}
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.
嗯,可以做 tegg 里面写一个示例文档?
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.
缺少一个 Guards 的抽象实现用户权限判断 https://docs.nestjs.com/guards
BREAKING CHANGE: only support egg >= 4.0.0
the first app on egg v4
eggjs/egg#3644