Skip to content

Add support-settings private-api endpoints - #45

Merged
feruzm merged 2 commits into
mainfrom
feature/support-settings
Jul 7, 2026
Merged

feruzm merged 2 commits into
mainfrom
feature/support-settings

Conversation

@feruzm

@feruzm feruzm commented Jul 7, 2026 •

Copy link
Copy Markdown
Member
  • Adds POST /private-api/support-settings and /private-api/support-settings-update, forwarding to the backend support-settings resource for the authenticated user.
  • Username is resolved from the validated code only, matching the streak-freeze handlers; the body can never override it.
  • Update payload is validated by an exported pure helper (both fields must be integers 0..100) with unit tests covering valid, boundary, out of range, float, string, boolean and missing cases.
  • Maps axios to its CJS build in the jest config so the existing test suite can load again under jest 26.

Summary by CodeRabbit

  • New Features

    • Added support settings endpoints so signed-in users can view and update their beneficiary and curation percentages.
  • Bug Fixes

    • Improved validation for percentage values, rejecting invalid, missing, or out-of-range inputs to prevent bad updates.
  • Tests

    • Expanded automated coverage for percentage parsing and existing request-header handling.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds private support-settings proxy endpoints. The main changes are:

  • New authenticated read and update handlers for support settings.
  • Strict validation for beneficiary and curation percentages.
  • Route registration for the new private-api endpoints.
  • Unit tests for the payload parser.
  • A Jest axios mapper for the CommonJS build.

Confidence Score: 5/5

The changed flow looks safe to merge after a small proxy consistency cleanup.

  • The auth-derived username path is preserved.
  • The update payload is validated before forwarding.
  • The read endpoint can drop query options that sibling read endpoints preserve.

src/server/handlers/private-api.ts

Important Files Changed

Filename Overview
src/server/handlers/private-api.ts Adds support-settings parsing and proxy handlers; the read handler does not forward query parameters like sibling read handlers.
src/server/index.tsx Registers the new support-settings private-api routes.
src/server/handlers/private-api.test.ts Adds unit tests for valid and invalid support-settings payloads.
package.json Maps axios to its CommonJS Node build for Jest.

Fix All in Claude Code

Reviews (1): Last reviewed commit: "feat: add support-settings private-api e..." | Re-trigger Greptile

if (!username) {
return;
}
pipe(apiRequest(`support-settings/${username}`, "GET"), res);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Support Settings Query Dropped

When a client calls /private-api/support-settings with query parameters, this handler drops them before proxying to the backend. The neighboring read handlers forward req.query, so any backend-supported support-settings options would be silently ignored and callers would receive the default response instead.

Suggested change
pipe(apiRequest(`support-settings/${username}`, "GET"), res);
pipe(apiRequest(`support-settings/${username}`, "GET", {}, {}, req.query), res);

Fix in Claude Code

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6ecc86b4-7fc8-4a7e-9ce7-a5e9b79a7d63

📥 Commits

Reviewing files that changed from the base of the PR and between c405736 and 6789aed.

📒 Files selected for processing (4)
  • package.json
  • src/server/handlers/private-api.test.ts
  • src/server/handlers/private-api.ts
  • src/server/index.tsx

📝 Walkthrough

Walkthrough

Adds a new parseSupportSettingsPayload validator and two authenticated endpoints (supportSettings, supportSettingsUpdate) for managing beneficiary_percent/curation_percent, wires corresponding routes, adds tests, and updates Jest config to map axios to its Node build.

Changes

Support settings feature

Layer / File(s) Summary
Payload validation and tests
src/server/handlers/private-api.ts, src/server/handlers/private-api.test.ts
Adds parseSupportSettingsPayload validating beneficiary_percent and curation_percent as integers within 0..100, returning null on invalid input; adds a test suite covering boundaries, invalid types, and missing/undefined bodies.
Authenticated GET/PUT handlers
src/server/handlers/private-api.ts
Adds supportSettings GET handler fetching settings via authenticated username, and supportSettingsUpdate PUT handler validating the body and forwarding updates upstream, returning 400 on invalid payloads.
Route registration
src/server/index.tsx
Registers two new POST routes for /private-api/support-settings and /private-api/support-settings-update wired to the new handlers.
Jest axios module mapping
package.json
Adds moduleNameMapper entry remapping axios to axios/dist/node/axios.cjs for tests.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ExpressRoute
  participant supportSettingsUpdate
  participant UpstreamAPI

  Client->>ExpressRoute: PUT /private-api/support-settings-update
  ExpressRoute->>supportSettingsUpdate: handle request
  supportSettingsUpdate->>supportSettingsUpdate: parseSupportSettingsPayload(req.body)
  alt invalid payload
    supportSettingsUpdate-->>Client: 400 error
  else valid payload
    supportSettingsUpdate->>UpstreamAPI: update support-settings/{username}
    UpstreamAPI-->>supportSettingsUpdate: response
    supportSettingsUpdate-->>Client: success response
  end
Loading

Poem

A rabbit hops with settings new,
Percentages checked, zero to ninety-two... and beyond to a hundred too!
GET and PUT routes hop in line,
Axios mapped just fine.
Thump thump — ship it, all is well! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding support-settings private API endpoints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/support-settings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@feruzm
feruzm merged commit 1b6a507 into main Jul 7, 2026
2 checks passed
@feruzm
feruzm deleted the feature/support-settings branch July 7, 2026 11:25
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.

1 participant