/** * Hono example — stripe-mpp-proxy * * Works on Node.js, Bun, Deno, and Cloudflare Workers. * * Node.js: * npm install hono @hono/node-server * npx tsx index.ts * * Cloudflare Workers — replace the serve() call with: * export default { fetch: app.fetch } */ import { Hono } from 'hono' import { createProxy } from '../../src/index.js' const proxy = createProxy({ stripe: { secretKey: process.env.STRIPE_SECRET_KEY!, networkId: process.env.STRIPE_NETWORK_ID ?? 'internal', }, services: { inference: { origin: process.env.INFERENCE_ORIGIN_URL!, routes: [ { method: 'POST', path: '/v1/infer', amount: '0.05', currency: 'usd', }, ], }, data: { origin: process.env.DATA_ORIGIN_URL!, routes: [ { method: 'GET', path: '/v1/records/*', amount: '0.01', currency: 'usd', }, ], }, }, }) const app = new Hono() app.all('*', (c) => proxy.fetch(c.req.raw)) const port = Number(process.env.PORT ?? 3000) // @ts-ignore – optional peer dep; remove when targeting Bun/CF Workers import { serve } from '@hono/node-server' serve({ fetch: app.fetch, port }) console.log(`[hono] stripe-mpp-proxy listening on http://localhost:${port}`)