var path=require("path"), basicAuth=require("basic-auth"); var cwd=process.cwd(); var globalAccounts=require(cwd+"/globalAccounts.json"); module.exports={ "serverdir":cwd, "webfilesdir":cwd+"/web_files", "persistdir":cwd+"/persist", "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