heroku-client
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -8,2 +8,5 @@ var https = require('https'), | ||
https.globalAgent.maxSockets = Number(process.env.HEROKU_CLIENT_MAX_SOCKETS) || 5000; | ||
module.exports = Request; | ||
@@ -22,3 +25,4 @@ | ||
_.bindAll(this); } | ||
_.bindAll(this); | ||
} | ||
@@ -25,0 +29,0 @@ |
{ | ||
"name": "heroku-client", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "A wrapper for the Heroku v3 API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/heroku.js", |
@@ -14,22 +14,63 @@ # heroku-client [![Build Status](https://travis-ci.org/jclem/node-heroku-client.png?branch=master)](https://travis-ci.org/jclem/node-heroku-client) | ||
```javascript | ||
// Create a new client and give it an API token | ||
var Heroku = require('heroku-client') | ||
, heroku = new Heroku({ token: user.apiToken }); | ||
/* | ||
* `heroku-client` works by providing functions that return proxy objects for | ||
* interacting with different resources through the Heroku API. | ||
* | ||
* To begin, require the Heroku module and create a client, passing in an API | ||
* token: | ||
*/ | ||
var Heroku = require('heroku-client'), | ||
heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN }); | ||
/* | ||
* The simplest example is listing a user's apps. First, we call `heroku.apps()`, | ||
* which returns a proxy object to the /apps endpoint, then we call `list()` to | ||
* actually perform the API call: | ||
*/ | ||
heroku.apps().list(function (err, apps) { | ||
console.log(apps); | ||
// `apps` is a parsed JSON response from the API | ||
}); | ||
heroku.apps('my-app').info(function (err, app) { | ||
console.log(app); | ||
/* | ||
* The advantage of using proxy objects is that they are reusable. Let's get the | ||
* info for the user's app "my-app", then get the dynos for the app, then | ||
* remove a collaborator: | ||
*/ | ||
var app = heroku.apps('my-app'); | ||
app.info(function (err, app) { | ||
// Details about the `app` | ||
}); | ||
heroku.apps().create({ name: 'my-new-app' }, function (err, app) { | ||
console.log(app); | ||
app.dynos().list(function (err, dynos) { | ||
// List of the app's `dynos` | ||
}); | ||
var newPlan = { plan: { name: 'papertrail:fixa' } }; | ||
heroku.apps('my-app').addons('papertrail').update(newPlan, function (err, addon) { | ||
console.log(addon); | ||
app.collaborators('user@example.com').delete(function (err, collaborator) { | ||
// The `collaborator` has been removed unless `err` | ||
}); | ||
/* | ||
* Requests that require a body are easy, as well. Let's add a collaborator to | ||
* the user's app "another-app": | ||
*/ | ||
var app = heroku.apps('another-app'), | ||
user = { email: 'new-user@example.com' }; | ||
app.collaborators().create({ user: user }, function (err, collaborator) { | ||
// `collaborator` is the newly added collaborator unless `err` | ||
}); | ||
``` | ||
@@ -39,3 +80,3 @@ | ||
heroku-client works with Node-style callbacks, but also implements promises with the [q][q] library. | ||
heroku-client works with Node-style callbacks, but also implements promises with the [Q][q] library. | ||
@@ -42,0 +83,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85191
2183
126
2