OMPX JavaScript SDK
    Preparing search index...

    OMPX server class with Express-specific middleware generation.

    import express from 'express'
    import { Ompx } from '@ompx/express'
    import { tempo } from '@ompx/tempo'

    const app = express()
    const ompx = Ompx.create({
    methods: [tempo({ recipient: '0x...', currency: '0x20c0...' })],
    })

    app.get('/api/data',
    ompx.charge({ amount: '0.01' }),
    (req, res) => {
    const settlement = res.locals.ompxSettlement
    res.json({ data: '...', payer: settlement.payer })
    }
    )
    Index

    Methods

    Methods

    • Returns an Express RequestHandler that enforces payment for the route.

      The middleware:

      1. Returns 402 with dual-protocol challenges if no payment is present
      2. Verifies and settles the payment
      3. Injects ompxSettlement and ompxProtocol into res.locals
      4. Wraps response methods (json/send/end) to inject receipt headers before sending

      Parameters

      Returns RequestHandler