Skip to content

feat: Cloudflare Worker Conversion#124

Open
zhaog100 wants to merge 1 commit into
ubiquity-os:developmentfrom
zhaog100:feat/cloudflare-worker
Open

feat: Cloudflare Worker Conversion#124
zhaog100 wants to merge 1 commit into
ubiquity-os:developmentfrom
zhaog100:feat/cloudflare-worker

Conversation

@zhaog100
Copy link
Copy Markdown

@zhaog100 zhaog100 commented Apr 9, 2026

Convert to Cloudflare Worker

Closes #92

Changes

New: src/worker.ts — Cloudflare Worker entry point

  • GET / — Health check endpoint returning service status and version
  • POST / — Webhook handler for permit generation and wallet registration
  • Full CORS support on all responses
  • Environment variable validation using TypeBox schemas
  • Structured error handling with proper HTTP status codes

Configuration

  • Updated wrangler.toml with proper Worker config, nodejs_compat flag, and secrets documentation
  • Added wrangler dev, wrangler deploy, and cf-build scripts to package.json
  • Updated tsup.config.ts to include the worker entry point

Node.js → Web API Migration

  • Replaced Buffer.from(...).toString("base64") with btoa() in encode-decode.ts
  • Replaced process.env.X25519_PRIVATE_KEY with context.env.X25519_PRIVATE_KEY in ERC20 permit handler (with fallback for backward compat)
  • Removed dotenv/config import from src/types/env.ts
  • Added X25519_PRIVATE_KEY to the environment schema

Backward Compatibility

  • The existing GitHub Actions entry point (src/main.ts) is preserved
  • The library exports (src/index.ts) remain unchanged
  • ERC20/ERC721 handlers work with both Context and Payload overloads as before

Testing

# Local development
npm run dev

# Health check
curl http://localhost:8787/

# Generate permits
curl -X POST http://localhost:8787/ \
  -H "Content-Type: application/json" \
  -d '{"eventName":"issues.closed","eventPayload":{...},"settings":{...},"authToken":"..."}'

- Added wrangler.toml configuration with secrets management
- Created src/worker.ts as CF Worker entry point
- Replaced Node.js Buffer with Web API btoa/atob
- Added X25519_PRIVATE_KEY to environment schema
- Replaced process.env access with context.env in ERC20 handler
- Removed dotenv dependency from env types
- Added health check endpoint (GET /)
- Added CORS support for all responses
- Added environment variable validation
- Updated package.json with wrangler dev/deploy scripts
- Updated tsup config to include worker entry

Closes ubiquity-os#92
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Warning

Rate limit exceeded

@zhaog100 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 20 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 27 minutes and 20 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85b2823b-9681-4cf3-b9fa-2126aad226b2

📥 Commits

Reviewing files that changed from the base of the PR and between 6bcfa62 and 3aa987d.

📒 Files selected for processing (7)
  • package.json
  • src/handlers/encode-decode.ts
  • src/handlers/generate-erc20-permit.ts
  • src/types/env.ts
  • src/worker.ts
  • tsup.config.ts
  • wrangler.toml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Unused dependencies (1)

Filename dependencies
package.json dotenv

Unlisted binaries (1)

Filename binaries
package.json wrangler

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.

Convert plugin to cloudflare worker

1 participant