1. 0

  2. 5

    Tl,dr: use an if-statement in Express middleware to redirect based on user feature flags.

    Yawn and flagged.


    Also, it looks like there may be a syntax error in their handler. Comments are mine, added:

    /* pretty sure that you need an = sign on your lambda arrow, folks */
    const featureFlaggedRouting = (req, res, next) > {
      /* what, I guess Node has an `If` library now? */
      If (req.user.featureFlagExists) {
        /* whoa tiger...Express middleware functions shouldn't be returning anything, least of all more middleware! */
        return newRoutingLogic(req, res, next)
      /* are we meaning to early-out above, or is this a bug? */

    Here, maybe you all will find the docs useful. :|

    Maybe try:

    const featureFlaggedRouting = (req, res, next) => {
      req.user.featureFlagExists? newRoutingLogic(req, res, next) : next() ;

    Note that, without an idea of what newRoutingLogic should be, my refactor could be incorrect.