Skip to content

Build cloud API docs lazily - #2065

Draft
RhysSullivan wants to merge 1 commit into
mainfrom
lazy-swagger
Draft

RhysSullivan wants to merge 1 commit into
mainfrom
lazy-swagger

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

apps/cloud/src/extensions/routes.ts built the Swagger UI page and the full OpenAPI spec at module scope, so every cold Worker isolate evaluated effect's ~2 MB Swagger bundle and walked all 91 endpoints before it could answer any request.

/api/docs and /api/openapi.json are now plain HttpRouter.add handlers. The Swagger bundle arrives through a dynamic import inside the handler, and the spec, the composed CloudOpenApi, and the rendered HTML are each memoized per isolate. The served page and JSON are unchanged — the HTML was diffed against HttpApiSwagger.layer output and is byte-identical.

Also removes apps/cloud/src/extensions/docs.ts and apps/cloud/src/api/router.ts, a second copy of the same composition that no runtime path reached, plus the one test suite that existed only to exercise it.

Evaluated module closure, apps/cloud/scripts/start-closure.mjs:

closure before after
API request (startup + app) 9.84 MB 7.95 MB
page request (startup + start) 9.86 MB 9.86 MB

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cloudflare preview

Console https://executor-preview-pr-2065.executor-e2e.workers.dev
MCP https://executor-preview-pr-2065.executor-e2e.workers.dev/mcp
Deployed commit adcb26c

Sign-in is Cloudflare Access (one-time PIN to an allowed email). The preview has its own database and encryption key; it is destroyed when this PR closes.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud adcb26c Sep 18 2026, 07:40 PM

@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@2065

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@2065

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@2065

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@2065

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@2065

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@2065

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@2065

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@2065

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@2065

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@2065

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@2065

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@2065

executor

npm i https://pkg.pr.new/executor@2065

commit: adcb26c

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing adcb26c Commit Preview URL

Branch Preview URL
Sep 18 2026, 07:38 PM

This branch has not been deployed

No deployments
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