135

Saw a rant about clean-up, wanted to share mine :3

Comments
  • 8
    Green does feel good.
  • 8
    Hi (I was the cleanup ranter)
  • 1
    @CraftedCart So now you aren't the cleanup ranter?!
  • 1
    @Mitiko Nope! Time to make a mess of the codebase again ;)
  • 2
    So... I can hack this simply by not sending the username or password params?
  • 2
    No, we just changed the middleware in our route definition from validateLogin to requireFields("username", "password") ans so on for the others form-validation middleware we used
  • 1
    The unittests passes with both code ;)
  • 4
    Nice use of the spread operator!

    @jespersh nah, look at it carefully, it is not an authenticator, just a field validator.
  • 3
    Party pooper here!
    Why a named "wrapped" function and not just return an arrow function directly?
    function requireFields(... fields) {
    return (req, res, next) => {
    ...
    }
    }
    And while at it, why not just use the lib 'Joi' for validation, much easier to create better validation rules
  • 1
    Tfw someone else posts your rant idea and gets a lot more upvotes.

    Jk. I'm good - don't worry about it.
  • 2
    @CraftedCart maybe there are more people doing JS than C ? Anyway yours got my ++ ;) @solocoder oops python habbit spotted, you're totally right, I should have used an arrow function. Don't know that lib, it'll be for the next project
Add Comment