Skip to content

Add test coverage for the config GET/PATCH endpoints and validation #82

Description

@mikewheeleer

Test the config read and update endpoints

Description

GET /api/v1/config and PATCH /api/v1/config in src/index.ts expose and mutate the config object (rateLimitPerWindow, rateLimitWindowMs, bulkMaxItems, eventLogCap), with the PATCH handler restricting writable keys to an allowlist and validating each value as a positive integer. None of this is tested: the allowlist enforcement, the positive-integer validation, and the read-back are all uncovered. This issue adds full coverage.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-backend only.
  • Assert GET /api/v1/config returns the current { config } with all expected keys.
  • Assert PATCH updates an allowed key (e.g. bulkMaxItems) and the change is visible on the next GET.
  • Assert PATCH rejects non-integer, zero, and negative values with 400 invalid_request and requestId.
  • Assert that a non-allowlisted key (e.g. eventLogCap) is silently ignored (not written), matching the handler's allowed list.
  • Restore any mutated config in afterEach so other suites are unaffected.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/config-34-coverage
  • Implement changes
    • Write comprehensive tests in: create src/__tests__/config.test.ts.
    • Add documentation: none beyond test names.
    • Snapshot and restore the config object between tests.
    • Validate security: include a non-allowlisted key and a type-confusion value (string, array).
  • Test and commit

Test and commit

  • Run npm run build, npm run lint, and npm test.
  • Cover edge cases: zero, negative, float, string value, non-allowlisted key.
  • Paste the full npm test output and a coverage summary in the PR.

Example commit message

test(config): cover config GET/PATCH validation and allowlist

Guidelines

  • Minimum 95 percent test coverage for impacted code.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions