var path=require("path"), basicAuth=require("basic-auth"); var cwd=process.cwd(); var globalAccounts=require(cwd+"/globalAccounts.json"); module.exports={ "rootdir":path.dirname(cwd), "serverdir":cwd, "simpleHTMLescape":function simpleHTMLescape(str){ return str.replace(/&/g,'&').replace(//g,'>'); }, "authgen":function authgen(accounts){ //omit `accounts` to use the globalAccounts list if(!accounts)accounts=globalAccounts; return function (req,res,next){ function unauth(res){ res.set("WWW-Authenticate","Basic realm=Authorization required"); return res.sendStatus(401); }; var user=basicAuth(req); if(!user||!user.name||!user.pass){ return unauth(res); } var i; for(i=0;i