feat: add additional user info#128
Conversation
|
I’m not sure if I should update |
f6d1a0b to
d04f86b
Compare
|
@ilyaliao is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughExtended the user profile response across the API to include four additional GitHub profile fields— Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@types/index.ts`:
- Around line 27-30: The GithubUser interface currently types company, location,
blog, and email as plain strings but the GitHub API may return null for these
fields; update the GithubUser definition so those properties are typed as string
| null (i.e., company: string | null; location: string | null; blog: string |
null; email: string | null) to match the API response and prevent type errors in
consumers of the GithubUser type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4bcfb8d8-fdf8-41a7-be76-b4cf0643e41b
📒 Files selected for processing (3)
README.mdroutes/users/[name]/index.tstypes/index.ts
| company: string; | ||
| location: string; | ||
| blog: string; | ||
| email: string; |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In the GitHub REST API "Get a user" response schema, are company, location, blog, and email nullable (string | null)?
💡 Result:
Yes, in the GitHub REST API "Get a user" (GET /users/{username}) response schema, the fields company, location, blog, and email are all nullable (type: string or null). This is confirmed in the official GitHub documentation for the response schema of related endpoints like GET /user (which shares the same schema), explicitly listing: - company: required, string or null - location: required, string or null - blog: required, string or null - email: required, string or null, format: email Additionally, schema definitions from API documentation tools (e.g., public-user schema) specify these fields as type: string, nullable: true. Real-world examples and notes in docs state that email is null if no public email is set, and similar logic applies to the others when not provided in the user's profile.
Citations:
- 1: https://docs.github.com/en/rest/users?apiVersion=2022-11-28
- 2: https://docs.github.com/en/enterprise-server@3.5/rest/users/users
- 3: https://docs.github.com/en/rest/users/users
- 4: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28
- 5: https://github.apidog.io/api-3489590
- 6: https://docs.github.com/en/enterprise-cloud@latest/rest/users/users?apiVersion=2022-11-28
Make the new GithubUser profile fields nullable.
Lines 27-30 are typed as string, but these GitHub profile fields can be null in the API response. The GitHub REST API "Get a user" endpoint returns company, location, blog, and email as string | null.
Suggested fix
export interface GithubUser {
id: string;
username: string;
name: string;
twitter: string;
avatar: string;
- company: string;
- location: string;
- blog: string;
- email: string;
+ company: string | null;
+ location: string | null;
+ blog: string | null;
+ email: string | null;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@types/index.ts` around lines 27 - 30, The GithubUser interface currently
types company, location, blog, and email as plain strings but the GitHub API may
return null for these fields; update the GithubUser definition so those
properties are typed as string | null (i.e., company: string | null; location:
string | null; blog: string | null; email: string | null) to match the API
response and prevent type errors in consumers of the GithubUser type.
resolves #127
This PR exposes additional user information in the user route.
Summary by CodeRabbit
New Features
Documentation