process admin keys at startup, instead of on demand

This commit is contained in:
ansuz 2019-03-28 17:17:40 +01:00
parent 64c9438734
commit 322ceb7ea1
1 changed files with 10 additions and 8 deletions

View File

@ -169,16 +169,18 @@ if (config.privKeyAndCertFiles) {
};
}
var admins = [];
try {
admins = (config.adminKeys || []).map(function (k) {
k = k.replace(/\/+$/, '');
var s = k.split('/');
return s[s.length-1].replace(/-/g, '/');
});
} catch (e) { console.error("Can't parse admin keys"); }
app.get('/api/config', function(req, res){
// TODO precompute any data that isn't dynamic to save some CPU time
var host = req.headers.host.replace(/\:[0-9]+/, '');
var admins = [];
try {
admins = (config.adminKeys || []).map(function (k) {
k = k.replace(/\/+$/, '');
var s = k.split('/');
return s[s.length-1].replace(/-/g, '/');
});
} catch (e) { console.error("Can't parse admin keys"); }
res.setHeader('Content-Type', 'text/javascript');
res.send('define(function(){\n' + [
'var obj = ' + JSON.stringify({