property-waterfall
Looks for a valid value in an object, iterating over a priority ordered array of keys.
Installation
npm i --save property-waterfall
Usage
const propertyWaterfall = // Look for IP in the following keys, in order.const order = 'ip' 'x-forwarded-for' 'x-real-ip' // IP could be in any of this objects, containing `order` keys.const object = ...reqheaders ...reqquery const ip = // If object['ip'] has a valid value, it will be returned,// else look for object['x-forwarded-for'],// else object['x-real-ip'].// According to order array priorities.