ip-whitelist
Basic middleware for whitelisting ip addresses
Looking for an ip-blacklist? Check out the pendant to this package at npm or GitHub
Usage
Install and save the package to your project npm i --save ip-whitelist
const ipWhitelist = path = ; // Use the predefined array callback// NOTE: Changes in the array you pass to ipWhitelist.array will not be considered!app; // Use the predefined file callback// NOTE: One line in the file represents an IP addressapp; // Create your own callbackapp; // Chain multiple callbacksapp;
More advanced usage
The default behaviour when handling a blocked IP is to end the request with status 403 and 'IP not whitelisted'.
To change that, pass a function as a second parameter to ipWhitelist()
. This function takes to arguments: req
and res
.
const ipWhitelist = ; let whitelist = ; app;app;app;