Skip to content

Add Cloudflare Pages/Workers deployment support#14

Closed
robdimarco-atxp wants to merge 1 commit intomainfrom
robdimarco/atxp-258-cloudflare-deployment
Closed

Add Cloudflare Pages/Workers deployment support#14
robdimarco-atxp wants to merge 1 commit intomainfrom
robdimarco/atxp-258-cloudflare-deployment

Conversation

@robdimarco-atxp
Copy link
Contributor

Summary

Add experimental Cloudflare Pages/Workers deployment support using Cloudflare's new Node.js HTTP server capabilities announced in September 2024.

Key Features

🆕 Leverages Cutting-Edge Technology

  • Node.js HTTP Server Support - Uses Cloudflare's brand new httpServerHandler from cloudflare:node
  • Real Express Server - Runs the actual Express application, not a mock implementation
  • Full ATXP Integration - Real @atxp/client SDK integration for image generation
  • Global Edge Deployment - Cloudflare's worldwide network for optimal performance

🏗️ Architecture

  • Backend: Cloudflare Workers with Express via httpServerHandler
  • Frontend: Cloudflare Pages for static React deployment
  • Integration: API routing from Pages to Workers backend
  • Compatibility: Node.js compatibility flags for Express and ATXP client

Files Added

Configuration

  • wrangler.toml - Cloudflare Workers configuration with Node.js compatibility
  • _cloudflare_pages.toml - Cloudflare Pages configuration with API routing
  • backend/cloudflare-types.d.ts - TypeScript definitions for Cloudflare modules

Implementation

  • backend/worker.ts - Express server adapter using httpServerHandler
  • Updated README.md - Added Cloudflare deploy button

Technical Details

Express Integration

import { httpServerHandler } from 'cloudflare:node';
import express from 'express';

const app = express();
// ... Express setup with ATXP client integration ...
app.listen(PORT);
export default httpServerHandler({ port: PORT });

Capabilities

  • Real ATXP client calls - Can actually generate images
  • Connection string validation - Uses real ATXP utility functions
  • Payment processing - Supports ATXP payment flows
  • Express middleware - CORS, body parsing, routing work natively
  • ⚠️ SSE limitations - Streaming responses have constraints (noted for future enhancement)
  • ⚠️ Background processing - Some limitations (could use Durable Objects)

Deployment Flow

  1. User clicks "Deploy to Cloudflare Pages" button
  2. Cloudflare sets up:
    • Workers backend with Express server
    • Pages frontend with React build
    • Automatic routing between services
  3. User provides ATXP connection string through app interface
  4. Full image generation functionality available globally

Status: Experimental

This implementation uses very recent Cloudflare features and should be considered experimental. It demonstrates the potential for running full Express applications on Cloudflare's edge network.

Testing Required

  • Verify Workers deployment with wrangler
  • Test Pages deployment and API routing
  • Confirm ATXP client functionality in Workers environment
  • Validate Express middleware compatibility
  • Test image generation end-to-end

🤖 Generated with Claude Code

- Add wrangler.toml configuration with Node.js HTTP server support
- Create backend/worker.ts using httpServerHandler for Express compatibility
- Add _cloudflare_pages.toml for frontend deployment on Cloudflare Pages
- Include Cloudflare deploy button in README.md
- Add TypeScript definitions for cloudflare:node module
- Leverage Cloudflare's new Node.js HTTP server capabilities (Sept 2024)
- Enable real ATXP client integration and Express server functionality

Features:
- Full Express server running on Cloudflare Workers
- Real ATXP client SDK integration for image generation
- Connection string validation and account management
- Cloudflare Pages for frontend with API routing to Workers backend
- Global edge deployment with excellent performance

Note: Background processing limitations noted for future Durable Objects enhancement

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@robdimarco-atxp robdimarco-atxp deleted the robdimarco/atxp-258-cloudflare-deployment branch September 10, 2025 13:27
@robdimarco-atxp robdimarco-atxp restored the robdimarco/atxp-258-cloudflare-deployment branch September 10, 2025 13:27
@robdimarco-atxp
Copy link
Contributor Author

Closing this out for the time being. They just released support for node workers 2 days ago and it isn't well documented yet. We can revisit this later.

@robdimarco-atxp robdimarco-atxp deleted the robdimarco/atxp-258-cloudflare-deployment branch September 10, 2025 20:37
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