Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
📝 WalkthroughWalkthroughAdds GitHub OAuth and starring support alongside existing Atproto auth: new GitHub composable and GitHub modal UI, AccountMenu updates to show GitHub connection and stacked avatars, server API routes for GitHub OAuth and star management, new shared schema and session github field, Atproto endpoints moved under Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 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: 8
🧹 Nitpick comments (3)
shared/schemas/github.ts (1)
3-6: Consider adding non-empty string validation forownerandrepo.
v.string()accepts empty strings, which would pass validation but fail silently at the GitHub API level. AminLength(1)pipe rejects these at the schema boundary.♻️ Suggested fix
export const GitHubStarBodySchema = v.object({ - owner: v.string(), - repo: v.string(), + owner: v.pipe(v.string(), v.minLength(1)), + repo: v.pipe(v.string(), v.minLength(1)), })server/api/auth/github/session.delete.ts (1)
3-11: Consider returning a structured JSON response for consistency.Other endpoints in this PR return JSON objects (e.g.,
{ starred: false }). Returning a plain string here makes it harder for clients to handle responses uniformly. A minor inconsistency, but worth aligning.Suggested fix
- return 'GitHub disconnected' + return { disconnected: true }server/api/github/star.put.ts (1)
7-47: Significant code duplication withstar.delete.ts.This handler is nearly identical to
star.delete.ts— the only differences are the HTTP method (PUTvsDELETE), theContent-Lengthheader, and the returnedstarredboolean. Consider extracting a shared helper to reduce duplication:Sketch of shared helper
// server/utils/github-star.ts export async function toggleGitHubStar(event: H3Event, method: 'PUT' | 'DELETE') { const session = await useServerSession(event) const github = session.data.github if (!github?.accessToken) { throw createError({ statusCode: 401, message: 'GitHub account not connected.' }) } const { owner, repo } = v.parse(GitHubStarBodySchema, await readBody(event)) // ... validation, fetch, error handling ... return { starred: method === 'PUT' } }Note: the path traversal concern flagged on
star.delete.tsapplies equally here.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (24)
app/components/Header/AccountMenu.client.vueapp/components/Header/AtprotoModal.client.vueapp/components/Header/GitHubModal.client.vueapp/composables/atproto/useAtproto.tsapp/composables/github/useGitHub.tsapp/composables/github/useGitHubStar.tsapp/pages/package/[[org]]/[name].vuei18n/locales/en.jsoni18n/schema.jsonlunaria/files/en-GB.jsonlunaria/files/en-US.jsonnuxt.config.tsserver/api/auth/atproto/index.get.tsserver/api/auth/atproto/session.delete.tsserver/api/auth/atproto/session.get.tsserver/api/auth/github/index.get.tsserver/api/auth/github/session.delete.tsserver/api/auth/github/session.get.tsserver/api/github/star.delete.tsserver/api/github/star.put.tsserver/api/github/starred.get.tsserver/utils/auth.tsshared/schemas/github.tsshared/types/userSession.ts
app/pages/package/[[org]]/[name].vue
Outdated
| <TooltipApp | ||
| v-if="isGitHubRepo && isGitHubConnected" | ||
| :text=" | ||
| isStarred ? $t('package.github_star.unstar') : $t('package.github_star.star') | ||
| " | ||
| position="bottom" | ||
| strategy="fixed" | ||
| > | ||
| <ButtonBase | ||
| size="small" | ||
| :title=" | ||
| isStarred ? $t('package.github_star.unstar') : $t('package.github_star.star') | ||
| " | ||
| :aria-label=" | ||
| isStarred ? $t('package.github_star.unstar') : $t('package.github_star.star') | ||
| " | ||
| :aria-pressed="isStarred" | ||
| :disabled="isStarActionPending" | ||
| :classicon="isStarred ? 'i-lucide:star text-yellow-400' : 'i-lucide:star'" | ||
| @click="toggleStar" | ||
| > | ||
| {{ compactNumberFormatter.format(stars) }} | ||
| </ButtonBase> | ||
| </TooltipApp> |
There was a problem hiding this comment.
Star count does not update after toggling.
stars (Line 914) comes from useRepoMeta, which fetches the repository metadata once. After toggleStar, isStarred updates via the optimistic UI in useGitHubStar, but stars remains stale — the count won't increment/decrement. This creates a confusing UX where the icon changes but the number doesn't.
Consider deriving a display count that adjusts based on the toggle delta:
const displayStars = computed(() => {
if (!isGitHubConnected.value) return stars.value
// Adjust based on the original fetched state vs current toggled state
// (requires tracking the initial starred state from the API)
...
})Alternatively, pass the stars value into useGitHubStar so it can return a reactive adjusted count.
|
Was attempting to update the star count, but it seems like GitHub's api doesn't immediately update. I can optimistically update the UI, but I'm not sure how to persist the star count on refresh/navigate (or if this even a priority). |
🔗 Linked issue
#479
🧭 Context
Implements GitHub OAuth, displays whether a repo is starred or not, and the ability to star/unstar through the UI. This does not implement the #32 portion.
Demo
demo.mp4
📚 Description
.envrequiresGITHUB_CLIENT_IDandGITHUB_CLIENT_SECRETfrom an OAuth app in order to run. The redirect uri needs to behttp://127.0.0.1:3000, nothttp://localhost:3000. This also needs to be the url that is visited in the browser in order for the cookie to persist properly.I renamed/moved some of the AT Protocol files to distinguish between the auth providers since there's more than one now. I based the GH auth off the existing AT route, and I didn't run into any issues, but it's been a while since I've manually handled oauth flows, so there's a chance I've missed an edge case or something.
For the starring API routes, I just left them all under
/githubbecause I wasn't sure if a/starpath was needed/wanted.