-
Notifications
You must be signed in to change notification settings - Fork 0
Complete Cloudflare worker-plane migration and production release path #47
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
Simplereally
merged 4 commits into
main
from
codex/cloudflare-worker-plane-release-ready
Mar 12, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5f9db0b
feat: complete cloudflare worker plane migration
a083531
fix: address review findings and worker hardening
eac720e
Apply repo fixes and worker updates
Simplereally 6fcb797
fix: harden worker lifecycle, lightbox UX, and batch state management
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Copy to .dev.vars for local Worker development only. | ||
| # Do not commit real secrets. | ||
|
|
||
| CONVEX_SITE_URL=https://your-deployment.convex.site | ||
| BLOOMSTUDIO_WORKER_SHARED_SECRET=replace-me | ||
| R2_PUBLIC_URL=https://your-public-r2-url.r2.dev | ||
| MEDIA_TRANSFORMS_BASE_URL=https://media.your-domain.com | ||
| CEREBRAS_API_KEY=replace-me | ||
| GROQ_API_KEY=replace-me | ||
| OPENROUTER_API_KEY=replace-me |
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 |
|---|---|---|
|
|
@@ -38,3 +38,6 @@ next-env.d.ts | |
| convex/_generated/ | ||
| .DS_Store | ||
| .env*.local | ||
| .dev.vars | ||
| .wrangler | ||
| worker-configuration.d.ts | ||
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,101 @@ | ||
| import crypto from "crypto" | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest" | ||
| import { NextRequest } from "next/server" | ||
| import { POST } from "./route" | ||
|
|
||
| const { mockAuth, mockDeleteImage } = vi.hoisted(() => ({ | ||
| mockAuth: vi.fn(), | ||
| mockDeleteImage: vi.fn(), | ||
| })) | ||
|
|
||
| vi.mock("@clerk/nextjs/server", () => ({ | ||
| auth: mockAuth, | ||
| })) | ||
|
|
||
| vi.mock("@/lib/storage", () => ({ | ||
| deleteImage: mockDeleteImage, | ||
| })) | ||
|
|
||
| function buildRequest(body: string): NextRequest { | ||
| return new NextRequest("http://localhost:3000/api/images/delete", { | ||
| method: "POST", | ||
| headers: { "content-type": "application/json" }, | ||
| body, | ||
| }) | ||
| } | ||
|
|
||
| describe("/api/images/delete", () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| vi.resetAllMocks() | ||
| }) | ||
|
|
||
| it("returns 400 for malformed JSON payloads", async () => { | ||
| mockAuth.mockResolvedValue({ userId: "user_123" }) | ||
|
|
||
| const response = await POST(buildRequest("{")) | ||
| const data = await response.json() | ||
|
|
||
| expect(response.status).toBe(400) | ||
| expect(data).toEqual({ | ||
| success: false, | ||
| error: { | ||
| code: "INVALID_JSON", | ||
| message: "Invalid JSON body", | ||
| }, | ||
| }) | ||
| expect(mockDeleteImage).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it("returns 400 when r2Key is missing", async () => { | ||
| mockAuth.mockResolvedValue({ userId: "user_123" }) | ||
|
|
||
| const response = await POST(buildRequest(JSON.stringify({}))) | ||
| const data = await response.json() | ||
|
|
||
| expect(response.status).toBe(400) | ||
| expect(data).toEqual({ | ||
| success: false, | ||
| error: { | ||
| code: "MISSING_KEY", | ||
| message: "Missing r2Key", | ||
| }, | ||
| }) | ||
| }) | ||
|
|
||
| it("returns 403 when user does not own the object key", async () => { | ||
| mockAuth.mockResolvedValue({ userId: "user_123" }) | ||
|
|
||
| const otherUserHash = crypto.createHash("sha256").update("different_user").digest("hex") | ||
| const response = await POST(buildRequest(JSON.stringify({ r2Key: `generated/${otherUserHash}/image.png` }))) | ||
| const data = await response.json() | ||
|
|
||
| expect(response.status).toBe(403) | ||
| expect(data).toEqual({ | ||
| success: false, | ||
| error: { | ||
| code: "FORBIDDEN", | ||
| message: "Not authorized to delete this image", | ||
| }, | ||
| }) | ||
| expect(mockDeleteImage).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it("deletes object when authenticated user owns the key", async () => { | ||
| const userId = "user_123" | ||
| mockAuth.mockResolvedValue({ userId }) | ||
|
|
||
| const userHash = crypto.createHash("sha256").update(userId).digest("hex") | ||
| const r2Key = `generated/${userHash}/image.png` | ||
|
|
||
| const response = await POST(buildRequest(JSON.stringify({ r2Key }))) | ||
| const data = await response.json() | ||
|
|
||
| expect(response.status).toBe(200) | ||
| expect(data).toEqual({ success: true }) | ||
| expect(mockDeleteImage).toHaveBeenCalledWith(r2Key) | ||
| }) | ||
| }) |
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.
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.