Repository navigation
Week 1: check and award API implementation - #248
Merged
Merged
Conversation
karthikeya1976
approved these changes
Oct 1, 2026
karthikeya1976
left a comment
Collaborator
There was a problem hiding this comment.
Verified both client functions against the real, live server routes (not just the PR's own description) — everything checks out:
checkAndAward(userId, token)— confirmedPOST /:userId/check-and-awardinroutes/badges.js:requireAuth+requireSelf("userId"), no body, response is{ awarded }. Also tracedrequireSelfitself — despite the param being nameduserId, it actually compares againstreq.user.username, so passing a username here (as the JSDoc says) is correct, not a bug.completeActivity(username, token, activityName)(newactivitiesApi.ts) — confirmedPUT /:username/activityinroutes/activities.jsexpects exactly{ activityName }in the body, matched byrequireActivityWriteAccess(self-or-admin, same pattern asrequireSelf). Correct as written.npx tsc --noEmiton this branch: clean, no type errors.
One small, non-blocking nit: completeActivity's JSDoc still says @param {string} activityId but the actual parameter (and the body key) is activityName — just the comment is stale, the code itself is right.
No unit tests yet (matches the PR's own honest checklist) — worth adding before this lane goes much further, but not a reason to hold this specific PR, since the signatures are independently verified against the real routes.
Approving — this unblocks Week 2/3 wiring as planned.
🤖 Generated with Claude Code
sruju333
force-pushed
the
checkAndAward
branch
from
October 5, 2026 20:23
adbc329 to
be60493
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
checkAndAwardto the badges API client and a newcompleteActivityfunction to the activities API client - the two endpoints with the clearest existing server support. Also traces thePUT /activities/:username/activitycall against the?taskId=deep link emitted inActivitiesModal.tsx:129, to identify where client-side wiring will need to go.Type of Change
Key Changes
core/services/badgesApi.ts: AddedcheckAndAward(userId, token), callingPOST /badges/:userId/check-and-award. Confirmed signature and response shape ({ awarded: [...] }) against the live server route (requireAuth+requireSelf, no body, server-authoritative recompute).core/services/activitiesApi.ts(new file): AddedcompleteActivity(username, token, activityName), callingPUT /activities/:username/activity. Confirmed request body shape ({ activityName }) against the live server route.?taskId=deep linkActivitiesModal.tsx:129emits when navigating to a puzzle/lesson. Confirmed it's currently read nowhere. Identified the puzzle-completion block inPuzzles.tsx(moveListRef.current.length === 0) as the right insertion point for the client-sidePUTcall. Found a mismatch worth flagging below.Testing
Bugs Fixed (if applicable)
N/A
TODO (Follow-up Work)
completeActivityandcheckAndAwardintoPuzzles.tsx's puzzle-completion block?taskId=(from the backend activity catalog'staskIdfield) doesn't match whatPUT /activities/:username/activityexpects (activities.name) - will need a lookup step client-side, or a server-side change, before the deep link can actually drive thePUTcallcompletedDateswrite on last-daily-activity completion inroutes/activities.jsAdditional Notes
Per Week 1 scope, this PR covers the two client functions plus tracing/identifying the wiring point - actual wiring is intentionally deferred to Week 2+/follow-up, per the plan.
Manual end-to-end testing was blocked locally by a
middlewarenodestartup error (Configuration property "indexKey" is not defined) - appears to be a missing local.envvalue, unrelated to this change. Function signatures and request/response shapes were verified by reading the confirmed server route handlers directly. Will complete manual testing once local env is sorted.