Skip to content

Deployment

Deploy ChostPulse to Cloudflare Workers, Vercel, or Netlify.

Prerequisites

  1. Node.js 20+: Download
  2. Account on chosen platform: Cloudflare, Vercel, or Netlify

Installation

Clone the repository and install dependencies:

git clone https://github.com/newlandpe/chost-pulse-worker.git
cd chost-pulse-worker
npm install

Deploy

1. Create KV Namespace

wrangler kv:namespace create PULSE_KV

Note the returned ID.

2. Configure wrangler.toml

Update wrangler.toml with your KV namespace ID:

name = "chost-pulse-worker"
main = "src/platforms/cloudflare.ts"
compatibility_date = "2024-09-23"

[[kv_namespaces]]
binding = "PULSE_KV"
id = "your-kv-namespace-id"

3. Deploy

npx wrangler deploy

1. Configure Redis (Upstash)

  • Create a Redis store in Vercel Storage or use Upstash directly.
  • Copy the REDIS_URL.

2. Configure Environment Variables

Set in Vercel project settings:

  • REDIS_URL - Your Redis connection URL

3. Deploy

npm run build:bundle
npx vercel deploy --prod

1. Initialize

netlify login
netlify init

2. Deploy

netlify deploy --prod

Netlify Blobs are configured automatically.

Verification

Test your deployed worker:

# Health check
curl https://your-domain.com/health

# Send a heartbeat
curl -X POST https://your-domain.com/api/heartbeat \
  -H "Content-Type: application/json" \
  -d '{
    "token": "sk_live_550e8400-e29b-41d4-a716-446655440000",
    "data": {
      "status": "online",
      "players": 10,
      "maxPlayers": 50,
      "tps": 20.0,
      "version": "1.0.0"
    }
  }'

# View a badge
curl "https://your-domain.com/api/badge?id=srv_pub_xxx&type=status"

Platform Comparison

Feature Cloudflare Vercel Netlify
Edge Locations 300+ 100+ 100+
Cold Start <1ms ~50ms ~50ms
Storage Cloudflare KV Vercel KV Netlify Blobs
Free Tier 100k/day 100k/month 125k/month

Updating

To update:

git pull
npm install
npm run deploy  # or platform-specific command