Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
spawn('createdb', ['nodebugme']).on('exit', function(code) {
if (code) {
console.log('failed! (tried "createdb nodebugme")')
return process.exit(1)
}
console.log('done.')
process.stdout.write('setting up "nodebugme" tables... ')
pg.connect(json.server.plugins.database, function(err, client, done) {
if (err) {
console.log('failed! (%s)', err.message)
return process.exit(1)
}
migrate(client, function(err) {
if (err) {
console.log('failed! (%s)', err.message)
return process.exit(1)
}
console.log('done.')
process.stdout.write('getting credentials for github sync... ')
ghauth({
noSave: true,
scopes: ['user'],
function onRun() {
newChangeSet();
pg.connect(conString, function(err, client, done) {
if (err) {
console.log('Error while connecting: ' + err);
done();
return;
}
domain.dbClient = client;
domain.done = done;
runDbTest();
});
}
function onRun() {
newChangeSet();
pg.connect(conString, function(err, client, done) {
if (err) {
console.log('Error while connecting: ' + err);
done();
return;
}
domain.dbClient = client;
domain.done = done;
runDbTest();
});
}
return function query(text, values, cb) {
if (typeof values === 'function') {
cb = values;
values = [];
}
pg.connect(connString, function(err, client, done) {
if (err) return cb(err);
client.query(text, values, function(err, result) {
done();
if (err) return cb(err);
return cb(err, result.rows, result);
});
});
};
};
function onrequest(request, next) {
var needsTransaction = request.route.handler && request.route.handler.needsTransaction
pg.connect(options, function(err, client, done) {
if (err) {
return next(err)
}
cache.set(request, {release: done, client: client})
request.db = client
request.querybox = getQueryBox(
options.analyze ?
executeAnalyze.bind(client) :
executeQuery.bind(client)
)
needsTransaction = needsTransaction && !client.inTransaction
if (needsTransaction) return client.query('BEGIN', function(err) {
debugDB('start transaction')
if (err) {
}
var config = require('./config.json')
ready = once(ready)
var github = new Github({
version: '3.0.0'
, protocol: 'https'
})
github.authenticate({
type: 'oauth'
, token: config.githubSyncToken
})
pg.connect(config.server.plugins.database, function(err, client, done) {
if (err) {
return ready(err)
}
var qbox = getQuerybox(function(qobj, ready) {
client.query(qobj.text, qobj.values, ready)
})
client.query('SELECT id, nbm_repo.user, name FROM nbm_repo', function (err, results) {
if (err) return ready(err)
var pending = results.rows.length
if (!pending) return end()
results.rows.forEach(function(repo) {