express-logic-middleware

Express middleware that provides logical checks on which set of middleware to run

Usage no npm install needed!

<script type="module">
  import expressLogicMiddleware from 'https://cdn.skypack.dev/express-logic-middleware';
</script>

README

express-logic-middleware

a small library of middlewares to help decide which set of middleware you should run

Each middleware takes in 3 arguments

  1. The name (or path) of the request variable you'd like to test.
  2. An array of middleware to run if the evaluation is truthy.
  3. An array of middleware to run if the evaluation is falsey.

ifReqVarIsUndefined - checks if request variable is equal to undefined. ifReqVarIsNull - checks if request variable is equal to null or undefined. ifReqVarIsTrue - checks if request variable is equal to true. ifReqVarIsFalse - checks if request variable is equal to false. ifTruthyInReq - checks if request variable is truthy. ifReqVarIs - Use this if you want to test if a request variable is equal to a specific field.