Repository navigation
Refresh the staging API from main #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
61d3718
Refresh the staging API from main
admdly 5df5046
Bound the staging API health check timeout
admdly 17bc615
Queue staging work without dropping pending deployments
admdly cea22a3
Clarify the fixed staging Preview identity
admdly 1e35e89
Revalidate the named staging directory over HTTP
admdly ea6c5e7
Clarify production and Preview cache invalidation setup
admdly cb55b31
Check staging using the deployed Preview URL
admdly 7c7e776
Merge branch 'main' into codex/automatic-staging-api
admdly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { afterEach, expect, it, vi } from "vitest"; | ||
| import { createCloudflareBindings } from "../../../../src/lib/adapters/cloudflare/index"; | ||
|
|
||
| afterEach(() => vi.unstubAllGlobals()); | ||
|
|
||
| it("uses the service binding for production and HTTP for the named staging Preview", async () => { | ||
| const bindingFetch = vi.fn( | ||
| async (_request: Request) => new Response(null, { status: 204 }) | ||
| ); | ||
| const httpFetch = vi.fn( | ||
| async (_request: Request) => new Response(null, { status: 204 }) | ||
| ); | ||
| vi.stubGlobal("fetch", httpFetch); | ||
| const request = () => | ||
| new Request("https://extensions.fossbilling.org/api/revalidate", { | ||
| method: "POST", | ||
| headers: { | ||
| authorization: "Bearer staging-secret", | ||
| "content-type": "application/json" | ||
| }, | ||
| body: JSON.stringify({ tags: ["extensions"] }) | ||
| }); | ||
| const production = createCloudflareBindings({ | ||
| EXTENSIONS_FRONTEND: { fetch: bindingFetch } | ||
| } as unknown as CloudflareBindings); | ||
| await production.services!.EXTENSIONS_FRONTEND(request()); | ||
| expect(bindingFetch).toHaveBeenCalledOnce(); | ||
| expect(httpFetch).not.toHaveBeenCalled(); | ||
|
|
||
| const staging = createCloudflareBindings({ | ||
| EXTENSIONS_FRONTEND_URL: | ||
| "https://staging-extensions.fossbilling.workers.dev" | ||
| } as unknown as CloudflareBindings); | ||
| await staging.services!.EXTENSIONS_FRONTEND(request()); | ||
| expect(httpFetch).toHaveBeenCalledOnce(); | ||
| const forwarded = httpFetch.mock.calls[0][0] as Request; | ||
| expect(forwarded.url).toBe( | ||
| "https://staging-extensions.fossbilling.workers.dev/api/revalidate" | ||
| ); | ||
| expect(forwarded.method).toBe("POST"); | ||
| expect(forwarded.headers.get("authorization")).toBe("Bearer staging-secret"); | ||
| expect(await forwarded.json()).toEqual({ tags: ["extensions"] }); | ||
| expect(bindingFetch).toHaveBeenCalledOnce(); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.