src/index.js
function mw(options) {
    // Defaults.
    const configuration = is.not.existy(options) ? {} : options;

    // Validation.
    if (is.not.object(configuration)) {
        throw new TypeError('Options must be an object!');
    }

    const attributeName = configuration.attributeName || 'clientIp';
    return (req, res, next) => {
        const ip = getClientIp(req);
        Object.defineProperty(req, attributeName, {
            get: () => ip,
            configurable: true
        });
        next();
    };
}
function mw(options) {
    // Defaults.
    const configuration = is.not.existy(options) ? {} : options;

    // Validation.
    if (is.not.object(configuration)) {
        throw new TypeError('Options must be an object!');
    }

    const attributeName = configuration.attributeName || 'clientIp';
    return (req, res, next) => {
        const ip = getClientIp(req);
        Object.defineProperty(req, attributeName, {
            get: () => ip,
            configurable: true
        });
        next();
    };
}
function mw ( options ) { // Defaults. const configuration = is . not . existy ( options ) ? { } : options ; // Validation. if ( is . not . object ( configuration ) ) { throw new TypeError ( 'Options must be an object!' ) ; } const attributeName = configuration . attributeName || 'clientIp' ; return ( req , res , next ) => { const ip = getClientIp ( req ) ; Object . defineProperty ( req , attributeName , { get : ( ) => ip , configurable : true } ) ; next ( ) ; } ; }
Expose request IP as a middleware.

@param {object} [options] - Configuration.
@param {string} [options.attributeName] - Name of attribute to augment request object with.
@return {*}
Expose request IP as a middleware .