Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
713 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,7 @@ coverage/ | |
.idea/ | ||
|
||
monkeyDB.json | ||
|
||
mochawesome-report/ | ||
|
||
privateConfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var _ = require('lodash'); | ||
var badge = require('gh-badges'); | ||
|
||
var achievements = require('require-all')({ | ||
dirname: appRoot + '/achievements', | ||
filter: /(.+achievement)\.js$/, | ||
excludeDirs: /^\.(git|svn)$/, | ||
recursive: true | ||
}); | ||
|
||
var badgeService = {}; | ||
|
||
badgeService.get = function(req, res) { | ||
badge.loadFont('./Verdana.ttf', function() { | ||
badge( | ||
{ | ||
text: [ | ||
'achievements', | ||
_.keys(achievements).length | ||
], | ||
colorA: '#894597', | ||
colorB: '#5d5d5d', | ||
template: 'flat', | ||
logo: [ | ||
'data:image/png;base64,iVBORw0KGgoAAAA', | ||
'NSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJL', | ||
'R0QA/wD/AP+gvaeTAAAA/0lEQVRYhe3WMU7DM', | ||
'BjFcadqh0qdWWBl7QU4Ss/AjsREF8RdOhYO0E', | ||
'qoN2DhFIgBOvBjIIMVxSFyUiEhP8lD7C/v/T9', | ||
'7sEMoKkoIe+Npn8qpOgCM2VBVVa1ZkzFDcjQd', | ||
'apDqLIR+u/jnO1AACkABKABdAO9DjHEWfb7lA', | ||
'LwOAQghXPXx6gJ4zE3GJIRwE0095Zhc4PO3iz', | ||
'7x7zoq+cB5bifr9tg0AK7xFZXcZYXXZjNs+wB', | ||
'giofG8hazbIDaeI5dFwAu8dxY2mE+KDyCWGCT', | ||
'YLj3c86xNliMEh5BVLjFseNEjnVN8pU0BsgSh', | ||
'5bwA5YnC25AVFjhpR6rk3Zd9K/1Dcae2pUn6m', | ||
'qiAAAAAElFTkSuQmCC' | ||
].join('') | ||
}, | ||
function(svg) { | ||
res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8'); | ||
res.setHeader('Pragma-directive', 'no-cache'); | ||
res.setHeader('Cache-directive', 'no-cache'); | ||
res.setHeader('Pragma','no-cache'); | ||
res.setHeader('Expires','0'); | ||
// Cache management - no cache, | ||
// so it won't be cached by GitHub's CDN. | ||
res.setHeader('Cache-Control', | ||
'no-cache, no-store, must-revalidate'); | ||
|
||
res.send(svg); | ||
} | ||
); | ||
}); | ||
}; | ||
|
||
module.exports = badgeService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
var _ = require('lodash'); | ||
var console = require('./consoleService')(); | ||
var nconf = require('nconf'); | ||
var auth = require('http-auth'); // @see https://github.com/gevorg/http-auth | ||
|
||
var allAchievibitConfigNames = [ | ||
'firebaseType', | ||
'firebaseProjectId', | ||
'firebasePrivateKeyId', | ||
'firebasePrivateKey', | ||
'firebaseClientEmail', | ||
'firebaseClientId', | ||
'firebaseAuthUri', | ||
'firebaseTokenUri', | ||
'firebaseAPx509CU', | ||
'firebaseCx509CU', | ||
'port', | ||
'databaseUrl', | ||
'stealth', | ||
'testDB', | ||
'logsUsername', | ||
'logsPassword', | ||
'ngrokToken' | ||
]; | ||
|
||
// look for config in: | ||
nconf | ||
.argv() | ||
.env({whitelist: allAchievibitConfigNames}) | ||
.file({ file: 'privateConfig.json' }); | ||
|
||
var configService = function() { | ||
|
||
var shouldSaveToFile = nconf.get('savePrivate'); | ||
|
||
if (shouldSaveToFile) { | ||
_.forEach(allAchievibitConfigNames, function(varName) { | ||
nconf.set(varName, nconf.get(varName)); | ||
}); | ||
|
||
nconf.save(function (err) { | ||
if (err) { | ||
console.error('problem saving private configuration'); | ||
} else { | ||
console.info('PERSONAL CONFIG SAVED! DELETE WHEN FINISHED!'); | ||
} | ||
}); | ||
} | ||
|
||
return { | ||
get: function(name) { | ||
return nconf.get(name); | ||
}, | ||
haveLogsAuth: !_.isNil(nconf.get('logsUsername')), | ||
createLogsAuthForExpress: function() { | ||
var basicAuth = auth.basic({ | ||
realm: 'achievibit ScribeJS WebPanel' | ||
}, function (username, password, callback) { | ||
var logsUsername = nconf.get('logsUsername') ? | ||
nconf.get('logsUsername') + '' : ''; | ||
|
||
var logsPassword = nconf.get('logsPassword') ? | ||
nconf.get('logsPassword') + '' : ''; | ||
|
||
callback(username === logsUsername && password === logsPassword); | ||
}); | ||
|
||
return auth.connect(basicAuth); | ||
} | ||
}; | ||
}; | ||
|
||
module.exports = configService; |
Oops, something went wrong.