Skip to content

Conversation

@Jakeii
Copy link
Member

@Jakeii Jakeii commented Nov 20, 2025

Depends on #14882

What does this change?

Refactor the Fastly client to be a bit more ergonomic, using client, service and dictionary classes. It's also been broken down into modules.

Not much has changed, the functions have moved to class methods, and have added utility methods to get instances of child classes:

const client = new FastlyClient(apiKey);

const service = client.getService(name);

const dictionary = service.getDictionary(id);

This is useful as the API url for dictionary operations needs the service id and version, which the getDictionary method can set up.

Why?

This came about as the currently client is coupled to config.ts which loads environment variables, with the class based client we can instantiate it with the API key and the consumer worries about how to get the API key.

The (WIP) lambda that will be deploying the ab test config in the future will get the keys and service name/ids from parameter store and not environment variables.

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

@Jakeii Jakeii force-pushed the jlk/ab-testing-fastly-client branch from ad7bfd0 to 1aac145 Compare November 21, 2025 16:34
@github-actions
Copy link

github-actions bot commented Nov 21, 2025

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

@Jakeii Jakeii marked this pull request as ready for review November 24, 2025 11:28
@Jakeii Jakeii requested a review from a team as a code owner November 24, 2025 11:28
@github-actions
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

Comment on lines +6 to +16
type MockedFetch = Mock<typeof fetch>;

function mockFetch(response: unknown, status = 200, statusText = "OK") {
const mockResponse = new Response(JSON.stringify(response), {
status,
statusText,
headers: { "Content-Type": "application/json" },
});

globalThis.fetch = mock.fn(async () => Promise.resolve(mockResponse));
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice fetch mock you got there ✨

cc @marjisound @JamieB-gu

@Jakeii Jakeii added run_chromatic Runs chromatic when label is applied maintenance Departmental tracking: maintenance work, not a fix or a feature labels Nov 27, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Nov 27, 2025
@Jakeii Jakeii merged commit 3da1e6c into main Nov 27, 2025
39 checks passed
@Jakeii Jakeii deleted the jlk/ab-testing-fastly-client branch November 27, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants