heroku/heroku-pg

View on GitHub
commands/killall.js

Summary

Maintainability
A
2 hrs
Test Coverage
'use strict'
 
const cli = require('heroku-cli-util')
const co = require('co')
 
function * run (context, heroku) {
const fetcher = require('../lib/fetcher')(heroku)
const host = require('../lib/host')
 
yield cli.action('Terminating connections for all credentials', co(function * () {
const db = yield fetcher.addon(context.app, context.args.database)
yield heroku.post(`/client/v11/databases/${db.id}/connection_reset`, {host: host(db)})
}))
}
 
Similar blocks of code found in 7 locations. Consider refactoring.
module.exports = {
topic: 'pg',
command: 'killall',
description: 'terminates all connections for all credentials',
needsApp: true,
needsAuth: true,
args: [{name: 'database', optional: true}],
run: cli.command({preauth: true}, co.wrap(run))
}