Skip to content

Conversation

@marklearst
Copy link
Owner

Add optional baseUrl parameter to FetcherOptions and MutatorOptions interfaces, allowing users to override the default Figma API base URL.

Why:

  • Enables testing against local mocks without patching constants
  • Supports proxy scenarios for enterprise environments
  • Allows integration with custom API gateways
  • Prepares for future self-hosted or alternative endpoints

Changes:

  • src/api/fetcher.ts: Added baseUrl option with default 'https://api.figma.com'
  • src/api/mutator.ts: Added baseUrl option with default 'https://api.figma.com'
  • tests/api/fetcher.test.ts: Added 3 tests for baseUrl override behavior
  • tests/api/mutator.test.ts: Added 3 tests for baseUrl override behavior

Usage:
const data = await fetcher('/v1/files/abc/variables/local', token, { baseUrl: 'http://localhost:3000' })

Note: When URL is already absolute (starts with http:// or https://), the baseUrl option is ignored.

Refs: Codex Audit Item #10

Add optional baseUrl parameter to FetcherOptions and MutatorOptions
interfaces, allowing users to override the default Figma API base URL.

Why:
- Enables testing against local mocks without patching constants
- Supports proxy scenarios for enterprise environments
- Allows integration with custom API gateways
- Prepares for future self-hosted or alternative endpoints

Changes:
- src/api/fetcher.ts: Added baseUrl option with default 'https://api.figma.com'
- src/api/mutator.ts: Added baseUrl option with default 'https://api.figma.com'
- tests/api/fetcher.test.ts: Added 3 tests for baseUrl override behavior
- tests/api/mutator.test.ts: Added 3 tests for baseUrl override behavior

Usage:
  const data = await fetcher('/v1/files/abc/variables/local', token, {
    baseUrl: 'http://localhost:3000'
  })

Note: When URL is already absolute (starts with http:// or https://),
the baseUrl option is ignored.

Refs: Codex Audit Item #10
Copilot AI review requested due to automatic review settings December 30, 2025 00:08
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.47%. Comparing base (78f89d7) to head (9537ec2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
+ Coverage   90.36%   90.47%   +0.10%     
==========================================
  Files          34       34              
  Lines         893      903      +10     
  Branches      245      246       +1     
==========================================
+ Hits          807      817      +10     
  Misses         85       85              
  Partials        1        1              
Flag Coverage Δ
unittests 90.47% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marklearst marklearst merged commit c96a36e into main Dec 30, 2025
8 checks passed
@marklearst marklearst deleted the feat/configurable-base-url branch December 30, 2025 00:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for configurable base URLs in the fetcher and mutator functions to enable testing against local mocks, proxy scenarios for enterprise environments, and integration with custom API gateways.

  • Added optional baseUrl parameter to FetcherOptions and MutatorOptions interfaces with default value of https://api.figma.com
  • Updated URL construction logic to use the configurable base URL instead of the hardcoded constant
  • Added comprehensive test coverage for base URL override scenarios

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/api/fetcher.ts Added baseUrl option to FetcherOptions interface and updated URL construction to use it
src/api/mutator.ts Added baseUrl option to MutatorOptions interface and updated URL construction to use it
tests/api/fetcher.test.ts Added tests covering custom baseUrl, default baseUrl, and absolute URL scenarios
tests/api/mutator.test.ts Added tests covering custom baseUrl, default baseUrl, and absolute URL scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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