Prerequisites
- Node.js installed
- Wrangler CLI installed
- Cloudflare account
- Pinata account with API key
- Stripe account with crypto payments enabled
Setup
1. Clone the Repository
2. Configure Environment Variables
Copy the example environment file and fill in your values:| Variable | Description |
|---|---|
PINATA_JWT | Your Pinata API JWT from the Pinata dashboard |
PINATA_GATEWAY_TOKEN | Gateway authentication token |
PINATA_GATEWAY_URL | Your Pinata gateway domain (e.g., your-gateway.mypinata.cloud) |
MPP_SECRET_KEY | 32-byte hex key for signing 402 challenges |
STRIPE_SECRET_KEY | Stripe API key with crypto payments preview access |
3. Local Development
http://localhost:8787.
4. Deploy
.dev.vars for deployed environments):
Architecture
The MPP Server is built with:Request Flow
- CORS middleware handles cross-origin requests
- MPP middleware intercepts
/v1/pin/*routes, calculates pricing, and manages the 402 challenge-response flow - Route handlers create signed Pinata upload URLs or proxy file downloads
- Stripe generates unique deposit addresses for each payment
Pricing Logic
Upload pricing is calculated per request based on file size:src/index.ts.