Skip to content

Add Bunny Edge deployment with edge runtime implementation#356

Closed
stefan-burke wants to merge 2 commits into
hunvreus:mainfrom
chobbledotcom:claude/bunny-edge-scripts-support-SOePk
Closed

Add Bunny Edge deployment with edge runtime implementation#356
stefan-burke wants to merge 2 commits into
hunvreus:mainfrom
chobbledotcom:claude/bunny-edge-scripts-support-SOePk

Conversation

@stefan-burke

Copy link
Copy Markdown

Summary

This PR adds a complete edge runtime implementation of Pages CMS designed to run on Bunny Edge Scripting (Deno 2.x based). The entire application—API routes and frontend—is bundled into a single deployable file for edge network execution.

Key Changes

  • Edge Runtime Architecture: New edge/ directory containing a complete reimplementation of the Pages CMS API and frontend serving layer optimized for edge runtimes

    • Replaces Next.js server-side code with lightweight, edge-compatible implementations
    • Removes heavy dependencies (Drizzle ORM, Lucia auth, Octokit) in favor of raw SQL and direct fetch calls
    • Uses libsql/Turso for database access instead of PostgreSQL
  • Core Libraries:

    • edge/lib/auth.ts: Session-based authentication with Web Crypto API for session ID generation
    • edge/lib/octokit.ts: Lightweight GitHub API client using direct fetch calls instead of the Octokit library
    • edge/lib/github-cache.ts: File cache management with raw SQL queries for libsql
    • edge/lib/token.ts: GitHub token management for both OAuth and GitHub App installation tokens
    • edge/lib/crypto.ts: AES-GCM encryption/decryption using Web Crypto API
    • edge/lib/db/client.ts: libsql database client with query helpers
    • edge/lib/file-utils.ts: File path utility functions
    • edge/middleware.ts: CSRF protection and security headers
  • API Routes: Complete port of Next.js API routes to edge-compatible handlers

    • Authentication: edge/routes/auth.ts (GitHub OAuth flow)
    • File operations: edge/routes/files.ts (create/update/delete)
    • Repository management: edge/routes/repos.ts, edge/routes/branches.ts
    • Content management: edge/routes/entries.ts, edge/routes/collections.ts, edge/routes/media.ts
    • Webhooks: edge/routes/webhook.ts (GitHub webhook handling)
    • Utilities: edge/routes/history.ts, edge/routes/rename.ts, edge/routes/collaborators.ts, edge/routes/cron.ts
  • Router & Entry Points:

    • edge/router.ts: Declarative HTTP router with pattern matching and typed route parameters
    • edge/routes/index.ts: Main route dispatcher with O(1) prefix dispatch
    • edge/entry.ts: Bunny Edge Script entry point
    • edge/server.ts: Deno development server entry point
  • Build System:

    • scripts/build-edge.ts: Build script that bundles edge entry point with inlined frontend assets into a single deployable file
    • deno.json: Deno configuration with tasks for development and building
    • .github/workflows/bunny-deploy.yml: GitHub Actions workflow for Bunny Edge deployment
  • Database:

    • edge/lib/db/schema.ts: SQLite DDL migrations (mirrors PostgreSQL schema)
    • edge/lib/db/migrations.ts: Migration runner for libsql
  • Testing: Comprehensive test suite for edge runtime components

    • edge/test/router_test.ts: Router pattern matching tests
    • edge/test/auth_test.ts: Session management tests
    • edge/test/octokit_test.ts: GitHub API client tests
    • edge/test/file_utils_test.ts: File utility function tests
    • edge/test/middleware_test.ts: CSRF and security header tests
    • edge/test/crypto_test.ts: Encryption/decryption tests
    • edge/test/schema_test.ts: Database schema tests
    • edge/test/env_test.ts: Environment variable abstraction tests
  • Documentation: edge/README.md with architecture overview and deployment guide

  • Configuration: Updated next.config.mjs to support static export when BUNNY_BUILD=true

Notable Implementation Details

https://claude.ai/code/session_01HvJvQSNapUyFfxaiPpapjH

claude added 2 commits March 17, 2026 09:13
Port the entire Pages CMS application to run on Bunny Edge Scripting
(Deno 2.x). This creates a parallel deployment target alongside the
existing Next.js/Vercel setup.

Key changes:
- edge/ directory with complete API route handlers ported from Next.js
- Custom HTTP router with pattern matching (based on tickets project)
- libsql/Turso database support replacing PostgreSQL/Drizzle ORM
- Session-based auth replacing Lucia (no Next.js cookie dependency)
- Lightweight GitHub API client replacing heavy octokit npm package
- esbuild build script that bundles API + inlined frontend assets
- Bunny Edge entry point (BunnySDK.net.http.serve) + Deno dev server
- GitHub Actions workflow for automated deployment to Bunny
- next.config.mjs updated to support static export via BUNNY_BUILD env

https://claude.ai/code/session_01HvJvQSNapUyFfxaiPpapjH
- Add 8 test files covering auth, crypto, env, file-utils, middleware,
  octokit, router, and schema modules (71 tests total, all passing)
- Switch test imports from deno.land to JSR @std/assert
- Fix router compilePattern to use single-pass replacement, preserving
  correct param name ordering when mixing :params and *catch-all
- Update deno.json with @std/assert dependency and test task

https://claude.ai/code/session_01HvJvQSNapUyFfxaiPpapjH
@stefan-burke stefan-burke deleted the claude/bunny-edge-scripts-support-SOePk branch March 17, 2026 09:56
@stefan-burke

Copy link
Copy Markdown
Author

whoops, i did not mean to create this in the main pagescms repo, my bad

@hunvreus

Copy link
Copy Markdown
Owner

I recommend you work form the development branch, I have made a LOT of changes in that new version. It will be released this week.

It introduces new features, upgrades across the board (new auth, Next.js 16, latest shadcn/ui, updated UI/UX) and a ton of bug fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants