Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
nodejitsu-api
Advanced tools
The nodejitsu-api
is a module that allows you to communicate with the our
RESTful API
This module is published in NPM:
npm install nodejitsu-api --save
The --save
tells NPM to automatically add it to your package.json
file
Before you can use the API you need to create a new API client. In this example
we are going to assume that foo
is your username and bar
is the password of
Nodejitsu account you want to control.
The createClient
method generates a new API client. It accepts an options
argument which is used to configure the client.
username
string The username of your Nodejitsu accountpassword
string The password or auth token of your accountremoteUri
string The Nodejitsu API resourcedebug
boolean Output debugging information to the consoleproxy
string HTTP proxy to connect overtimeout
number How long can a single API requests before we time it outignorePoweredBy
boolean Ignore the check for the x-powered-by
headerThis options argument can either be an object with the properties specified above or a nconf object.
The remoteUri
argument is a required argument. Most API calls also require the
username
and password
to be specified. There a couple of API call where this
is not required, this is documented by the relevant API calls.
var api = require('nodejitsu-api');
// Construct a new client.
var client = api.createClient({
username: 'foo',
password: 'bar',
remoteUri: 'https://api.nodejitsu.com'
});
The API calls are generally constructed as resource
and action
:
client.resource.action('data', function (err, result) {
if (err) {
throw err;
}
// Use the result
});
The following API resources are exposes in the module:
Checks if the available of the applications name and sub domain is currently taken in Nodejitsu.
app
string The application namecallback
functionclient.app.available('my-application', function (err, data) {
console.log(data);
});
List all the applications for the authenticated user.
username
string The username, which is optional and will default to the
configured usernamecallback
function The callback receives an array of your applicationsclient.app.list('my-application', function (err, data) {
console.log(data);
});
Create an application from the specified package.json
object.
app
object The package.jsoncallback
functionvar app = require('./package.json'); // requires your package.json as example
client.apps.create(app, function (err, data) {
console.log(data);
});
Views the application details for one specific application.
app
string Name of the applicationcallback
function The callback receives your application detailsclient.apps.view('my-application-name', function (err, data) {
console.log(data);
});
Updates the the application details.
app
string Name of the applicationchanges
Object Properties that need to be updated for this applicationcallback
functionclient.apps.update('my-application-name', { name: 'foo' }, function (err, data) {
console.log(data);
});
Start the application.
app
string Name of the applicationcallback
functionclient.apps.start('my-application-name', function (err, data) {
console.log(data);
});
Stop the application.
app
string Name of the applicationcallback
functionclient.apps.stop('my-application-name', function (err, data) {
console.log(data);
});
Restarts the application without changing a drone. Where stopping and starting an application could result in deployment on a different drone.
app
string Name of the applicationcallback
functionclient.apps.stop('my-application-name', function (err, data) {
console.log(data);
});
Run the application on x
amount of drones on the Nodejitsu servers.
app
string Name of the applicationdrones
number The amount of drones the application needs to run oncallback
functionclient.apps.setDrones('my-application-name', 10, function (err, data) {
console.log(data);
});
Move the application to a new datacenter.
app
string Name of the applicationcloud
object The datacenter configuration
provider
string Name of the cloud providerdatacenter
string Data center identifierdrones
number The amount of drones you want to start on this datacentercallback
functionvar cloud = {
provider: 'joyent',
datacenter: 'eu-ams-1',
drones: 6
}
client.apps.datacenter('my-application-name', cloud, function (err, data) {
console.log(data);
});
Destroys the application.
app
string Name of the applicationcallback
functionclient.apps.destroy('my-application-name', function (err, data) {
console.log(data);
});
Get a list of all datacenter providers and datacenter identifiers. Please note: this method doesn't require any authentication.
callback
functionclient.apps.destroy('my-application-name', function (err, data) {
console.log(data);
});
Create a new database. These databases are created by third party providers you can find more information about each database provider in webops/databases
type
string Database type (mongo, monghq, redis, redistogo, couch)name
string Name of the databasecallback
functionclient.databases.create('redis', 'my-iriscouch-redis-db', function (err, data) {
console.log(data);
});
Get the database information which contains the connection details
name
string Name of the databasecallback
functionclient.databases.get('my-iriscouch-redis-db', function (err, data) {
console.log(data);
});
Get the all databases and their information.
username
string The username, which is optional and will default to the
configured usernamecallback
functionclient.databases.list('username', function (err, data) {
console.log(data);
});
Destroy the specified database.
name
string Name of the database you want to destroycallback
functionclient.databases.list('username', function (err, data) {
console.log(data);
});
Fetches the logs for the given application.
name
string Name of the applicationamount
number The amount logs to retrievecallback
functionclient.logs.byApp('my-application', 50, function (err, data) {
console.log(data);
});
Fetches the logs for every application for the specified user.
username
string The username, which is optional and will default to the
configured usernameamount
number The amount logs to retrievecallback
functionclient.logs.byUser('foo', 50, function (err, data) {
console.log(data);
});
Lists all snapshots for the given application
name
string Name of the applicationcallback
functionclient.snapshots.list('my-application', function (err, data) {
console.log(data);
});
Uploads a new snapshot for the application. This method assumes that you have a
properly packed .tgz
application on your system. The .tgz
should have the
same internal structure as the result of an npm pack
.
name
string Name of the application that receives the snapshotsnapshotname
: string Name of the snapshotlocation
: string absolute path to the .tgz
snapshotcallback
functionclient.snapshots.create('my-application', '0.1.0', '/app.tgz', function (err, data) {
console.log(data);
});
Please note that this method returns an event emitter which you can use to track
the progress of the upload. This event emitter emits and data
event with the
amount of data uploaded and emits the end
event once the upload been
completed.
Fetches the snapshot from your application. Please note that these snapshots are
the actual state of the application that is ran on the drones, so these will
contain the node_modules
folder.
name
string Name of the applicationsnapshotname
string Name of the snapshot that you want to downloadcallback
functionclient.snapshots.fetch('my-application', '0.1.0', function (err, data) {
console.log(data);
});
This function returns the Stream that fetches the snapshot. You can use
this Stream to Stream.pipe
it to a file on your system. The callback would
only indicate a successful fetch.
Destroy the snapshot.
name
string Name of the applicationsnapshotname
string Name of the snapshot that you want to downloadcallback
functionclient.snapshots.destroy('my-application', '0.1.0', function (err, data) {
console.log(data);
});
Activates a snapshot. This allows you to roll back to a old version when something goes wrong in your application.
name
string Name of the applicationsnapshotname
string Name of the snapshot that you want to downloadcallback
functionclient.snapshots.activate('my-application', '0.0.45', function (err, data) {
console.log(data);
});
Tests if the users login details are valid.
callback
functionclient.users.auth(function (err, authenticated) {
console.log(authenticated);
});
Register a new Nodejitsu account. Please note: this method doesn't require any authentication.
account
object account details
username
string usernamepassowrd
string passwordemail
string e-mail address that receives the verification codecallback
functionvar account = {
username: 'foo',
password: 'bar',
email: 'foo@example.com'
};
client.users.create(account, function (err, data) {
console.log(data);
});
Test if the username is available. Please note: this method doesn't require any authentication.
username
string usernamecallback
functionclient.users.available('foo', function (err, data) {
console.log(data);
});
Retrieves the user details.
username
string usernamecallback
functionclient.users.view('foo', function (err, data) {
console.log(data);
});
Confirm the e-mail address of the user. Please note: this method doesn't require any authentication.
user
object confirmation details
username
string the username that we are confirminginviteCode
string the inviteCode that was send to the users e-mailcallback
functionvar user = {
username: 'foo',
inviteCode: 'foo-bar-bnanan-trololol'
};
client.users.confirm(user, function (err, data) {
console.log(data);
});
Request a password reset e-mail
username
string usernamecallback
functionclient.users.forgot('foo', function (err, data) {
console.log(data);
});
Updates the account information.
username
string usernamechanges
Object Properties that need to be updated for this user.callback
functionclient.users.update('foo', changes, function (err, data) {
console.log(data);
});
Removes your account from the Nodejitsu platform. Use with extreme caution. This will also destroy all the applications that you are running and databases that you have created. Once you call this method, there is no way back and no option to undo this.
username
string usernamecallback
functionclient.users.destroy('foo', function (err, data) {
console.log(data);
});
All tests are written with vows and should be run with npm:
$ npm test
MIT.
FAQs
nodejitsu API client wrapper
The npm package nodejitsu-api receives a total of 46 weekly downloads. As such, nodejitsu-api popularity was classified as not popular.
We found that nodejitsu-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.