79752640

Date: 2025-09-01 14:35:24
Score: 0.5
Natty:
Report link

I just published a package for this purpose:
https://www.npmjs.com/package/express-switchware

Usage:

const stripeHandler: express.RequestHandler = (req, res) =>
  res.send("Processed payment with Stripe");
const paypalHandler: express.RequestHandler = (req, res) =>
  res.send("Processed payment with PayPal");

app.post(
  "/checkout",
  expressSwitchware(
    (req) => req.body.provider, // e.g. { "provider": "stripe" }
    {
      stripe: stripeHandler,
      paypal: paypalHandler,
    }
  )
);

I think it is simple and elegant.

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: Crizant