Skip to content

feat(examples): add basic Express app with x402charity middleware#20

Open
bimakw wants to merge 1 commit intoallscale-io:mainfrom
bimakw:feat/express-basic-example
Open

feat(examples): add basic Express app with x402charity middleware#20
bimakw wants to merge 1 commit intoallscale-io:mainfrom
bimakw:feat/express-basic-example

Conversation

@bimakw
Copy link
Copy Markdown

@bimakw bimakw commented Mar 7, 2026

What

Add a minimal Express example app under examples/express-basic/ that demonstrates the x402charity middleware in action, resolving #2.

Changes

examples/express-basic/
├── package.json    # Dependencies: express + x402charity
├── README.md       # Setup instructions and configuration docs
└── index.js        # Simple Express app with x402charity middleware

How it works

  1. Install dependencies with npm install
  2. Set PRIVATE_KEY env var (Base Sepolia testnet wallet with USDC)
  3. Run npm start
  4. Every HTTP request triggers a $0.001 USDC micro-donation via the x402 protocol

Features

  • 3 demo routes: / (info), /hello (greeting), /health (uptime)
  • Non-blocking: Donations happen asynchronously, requests are never delayed
  • Testnet safe: Configured for Base Sepolia by default
  • Production ready: README includes instructions for switching to mainnet

Testing

cd examples/express-basic
npm install
export PRIVATE_KEY=0xYOUR_TEST_KEY
npm start

# In another terminal:
curl http://localhost:3000/hello

Closes #2

Add a minimal Express example under examples/express-basic/ that
demonstrates the x402charity middleware for automatic micro-donations.

- Simple Express server with 3 routes
- x402charity middleware configured for Base Sepolia (testnet)
- README with setup instructions and configuration docs
- Works out of the box with npm install && npm start

Closes allscale-io#2
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 7, 2026

@bimakw is attempting to deploy a commit to the shawnpang's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Build an example integration: Express app with automatic donations

1 participant