Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add+update user; create\delete webhook * create two api end-points one to authenticate and another one to create\delete webhooks (currently I'm sending the githubToken to the client and it sends it back when creating a webhook. need to keep only the firebaseToken on the client side * install missing dependency for firebase-admin * Simplify our console service to create defaults (show time and location) * change consoleService call * change consoleService call + fix status warning + add missing code currently, written as a comment since I need to also import the **account key** in some fancy way * move consoleService into app/models folder * implement api functions inside files * add api file * use api file inside index.js * ignore mocha reports * NEVER save private config file private config file should make it easier to save configuration to disk (DB url, etc) * save and require Q in our project (missing previous commit) * change order in api so routes won't override other routes * create new configuration service this will handle all configurations (also will save the configuration you add as argv if you add --savePrivate) I still need to make this simpler, but it's already simpler than the previous one :-) * use new configService + uncomment firebase admin initialization * put savePrivate inside configurationService * remove traces of nconf in other files * lint * make sure `updateWith` object is defined * get the firebase admin from userService later, should replace this with a function that does this internally * expose authenticateUsingToken instead of the defaultAuth object * also use authenticateUsingToken internally for tests * basic structure for userService specs I want to change the functions inside userService to not use req and res so that it will be simpler to test. after that change, I'll change this to test the actual file and not the function I mocked a few lines before :-) * iif not all firebase admin vars are set, don't authenticate * change userService model structure to support easier tests * write mocks to help test individual files * add some tests for userService auth functions * comment out e2e and check how to fix the tests timing-out
- Loading branch information
1 parent
8f12be2
commit c87b12c
Showing
19 changed files
with
1,244 additions
and
424 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.