Skip to content
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

feat(server/routes): 扩展 createServerRoutes 方法,允许定制 route 的内容。 #11033

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

YdreamW
Copy link
Contributor

@YdreamW YdreamW commented Apr 25, 2023

No description provided.

@vercel
Copy link

vercel bot commented Apr 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
umi ⬜️ Ignored (Inspect) Apr 25, 2023 1:24am

@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (662b16a) 29.21% compared to head (d4cdcaa) 29.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11033      +/-   ##
==========================================
- Coverage   29.21%   29.21%   -0.01%     
==========================================
  Files         479      479              
  Lines       14385    14386       +1     
  Branches     3381     3382       +1     
==========================================
  Hits         4203     4203              
- Misses       9455     9456       +1     
  Partials      727      727              
Impacted Files Coverage Δ
packages/server/src/routes.ts 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sorrycc sorrycc merged commit 2663a5c into umijs:master Apr 25, 2023
@@ -3,12 +3,14 @@ import { IRoute, IRoutesById } from './types';
export function createServerRoutes(opts: {
routesById: IRoutesById;
parentId?: string;
createRoute?: (opts: { route: IRoute }) => any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个类型把下面的 route.xxx 使用的类型安全破坏了,得严谨一点,用 typeof createServerRoute

Copy link
Contributor Author

@YdreamW YdreamW Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但是用户传进来的 createRoute 返回值应该可以不是 createServerRoute 方法的返回值类型

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

至少要拥有原对象的字段,逻辑会执行不下去,可以把返回值扩展一下:

export interface IRouteCustom extends IRoute {
  [key: string]: any
}

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.

None yet

3 participants