Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fetchSourceCodeFromGithubRepo () {
// console.log('fetch source code from github')
// in the middleware configuration, assume we already have an access token
// access token must be done through github oauth login
var token = config.token;
if (typeof token === "undefined") {
throw new Error('token is a required option!');
}
var client = github.client(token);
var repo = config.repo || "Stackvana/microcule-examples";
var branch = config.branch || "master";
var main = config.main || "index.js";
var ghrepo = client.repo(repo, branch);
ghrepo.contents(main, function (err, file) {
if (err) {
return config.errorHandler(err, next);
}
req.code = base64Decode(file.content).toString();
next();
provider.set(key, req.code, function(err, _set){
});
});
var _ = require('lodash');
var Q = require('q');
var configService = require('./app/models/configurationService')();
var CONFIG = configService.get();
var dbLibrary = CONFIG.testDB ? 'monkey-js' : 'monk';
var monk = require(dbLibrary);
var async = require('async');
var utilities = require('./utilities');
var github = require('octonode');
var request = require('request');
var colors = require('colors');
var client = github.client({
username: CONFIG.githubUser,
password: CONFIG.githubPassword
});
var console = require('./app/models/consoleService')();
var url = CONFIG.databaseUrl;
var db = monk(url);
var apiUrl = 'https://api.github.com/repos/';
var collections = {
repos: db.get('repos'),
users: db.get('users'),
// uses to store additional private user data
userSettings: db.get('auth_users')
};
}).login(['user', 'repo', 'gist'], function(err, id, token) {
settings.token = token; // save the client token
settings.client = github.client(settings.token); // create a client object
settings.client.get('/user', function(err, status, body) { // get user details
settings.info = body;
});
ghgist = settings.client.gist(); // create a reference to gist api
res.send({
id: id,
token: token,
err: err
});
});
}
})
})
console.log('Saving the write&read methods for each packets to config');
if (botManager.config["lastVersionReleasedIsBeta"]) {
config["packetInfoBeta"] = secondPart;
} else {
config["packetInfoRelease"] = secondPart;
}
console.log('Authentificating to github');
var githubClient = github.client(botManager.config['githubToken']);
var toFilter = secondPart.split('\n');
for (var i = 0; i < toFilter.length; i++) {
if ((toFilter[i].includes("BinaryStream") && (toFilter[i].includes("getB") || toFilter[i].includes("writeB") || toFilter[i].includes("writeF") || toFilter[i].includes("writeN") || toFilter[i].includes("writeS") || toFilter[i].includes("writeU") || toFilter[i].includes("writeV") || toFilter[i].includes("getD") || toFilter[i].includes("getF") || toFilter[i].includes("getI") || toFilter[i].includes("getS") || toFilter[i].includes("getT") || toFilter[i].includes("getV") || toFilter[i].includes("getU"))) || toFilter[i].includes('# ') || toFilter[i].includes("```")) {
if (toFilter[i].includes("#")) {
fixedText = fixedText + "\n\n" + toFilter[i].replace("@plt", "");
} else {
fixedText = fixedText + "\n" + toFilter[i].replace("@plt", "");
}
}
}
console.log('Posting on github the protocol documentation..');
async function updateGitHubStatus(appInfo, appID, commit, status, text) {
var url = config.address + ':' + config.port + '/result/' + appID + '/' + commit;
await updateStatus(appInfo, appID, commit, status, text);
if (commit === "HEAD") return;
if (appInfo.github !== undefined) {
var githubClient = github.client(appInfo.github);
var ghrepo = githubClient.repo(appInfo.repo);
try {
await ghrepo.statusAsync(commit, {
"state": status,
"target_url": url,
"description": text
});
} catch (error) {
console.log('Did not update commit status on repo ' + appInfo.repo + ': ' + error.message);
}
}
}
var fork = function(req, res, callback) {
var token = req.query.token || req.session.authCache.github.accessToken,
client = github.client(token);
if (typeof client === "undefined") {
res.send({
status: false,
message: "unauthorized"
});
return false;
}
var ghme = client.me();
//Get user repos and start process
ghme.repos(function(err, data) {
if (err) { GhApiOnErr(req, res, err); return; }
app.get('/api/friends', ensureAuthenticated, function(req, res) {
var github_client = github.client(req.user.oauth_token);
github_client.requestDefaults['qs'] = {page:1, per_page: 100};
var ghme = github_client.me()
ghme.followers(function(err, followers){
if (!err && res.statusCode == 200){
ghme.following(function(err, following){
if (!err && res.statusCode == 200){
var friends = _.unionWith(followers,following, function(friend1,friend2){
return friend1.id == friend2.id
});
friends.push({
function getInitialReposDataFrom(username) {
let client = github.client(my.github.ACCESS_TOKEN)
return new Promise((accept, reject) => {
client.get('/user/repos', {}, function (err, status, body, headers) {
let repos = []
for(let repo of body) {
if (repo.owner.login == username) {
repos.push({
name: repo.name,
url: repo.html_url,
description: repo.description,
stars: repo.stargazers_count,
forks: repo.forks_count,
export default (config) => githubApi(octonode.client(config.github));