Skip to content

Is the express middleware suitable for protecting routes with irreversible server-side operations? #1886

@kwkr

Description

@kwkr

I'm evaluating x402 for protecting routes that execute server-side logic, not just return static content.

app.use(
  paymentMiddleware(
    {
      "GET /api/:id": {
        accepts: {
          scheme: "exact",
          price: "$0.10",
          network: "eip155:84532",
          payTo: "0xMyAddress",
        },
        description: "Execute paid operation by ID",
      },
    },
    resourceServer,
  ),
);

app.get("/api/:id", (req, res) => {
  performOperation(req.params.id);
  res.json({ result: "done" });
});

Is this a supported use case? The examples in the docs mostly show static content being served. I want to make sure the payment middleware is designed to work with dynamic parameterized routes that perform actual operations before I build on top of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions