0.3.0 • Published 9 years ago

now-api v0.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

𝚫 now API Build Status

Node.js module to interact with the official 𝚫 now API.

You need to provide your API token, which you can obtain here. It is possible to pass it as a parameter or with the NOW_TOKEN environment variable. When no token is given, it will use the one contained in your .now.json file.

npm install --save now-api

Example

var Now = require('now-api');

var now = Now('YOUR TOKEN');

// Supports Promises
now.getDeployments().then((deployments) => {
    console.log(deployments);
}).catch((err) => {
    console.error(err);
});

// Or go old-school with callbacks
now.getDeployments(function(err, deployments) {
    if (err) throw err;
    console.log(deployments);
});

API Reference

Kind: global class

new Now(token)

Initializes the API. Looks for token in ~/.now.json if none is provided.

ParamTypeDescription
tokenStringYour now API token.

now.getDeployments(callback) ⇒ Promise

Returns an array with all deployments.

Kind: instance method of Now
See: https://zeit.co/api#list-endpoint

ParamTypeDescription
callbackfunctionCallback will be called with (err, deployments)

now.getDeployment(id, callback) ⇒ Promise

Returns an object with deployment data.

Kind: instance method of Now
See: https://zeit.co/api#get-endpoint

ParamTypeDescription
idStringID of deployment
callbackfunctionCallback will be called with (err, deployment)

now.createDeployment(body, callback) ⇒ Promise

Creates a new deployment and returns its data.

Kind: instance method of Now
See: https://zeit.co/api#instant-endpoint

ParamTypeDescription
bodyObjectObject a package key (for package.json data). The other keys should represent a file path, with their respective values containing the file contents.
callbackfunctionCallback will be called with (err, deployment)

now.deleteDeployment(id, callback) ⇒ Promise

Deletes a deployment and returns its data.

Kind: instance method of Now
See: https://zeit.co/api#rm-endpoint

ParamTypeDescription
idStringID of deployment
callbackfunctionCallback will be called with (err, deployment)

now.getFiles(id, callback) ⇒ Promise

Returns an array with the file structure.

Kind: instance method of Now
See: https://zeit.co/api#file-structure-endpoint

ParamTypeDescription
idStringID of deployment
callbackfunctionCallback will be called with (err, fileStructure)

now.getFile(id, fileId, callback) ⇒ Promise

Returns the content of a file.

Kind: instance method of Now
See: https://zeit.co/api#file--endpoint

ParamTypeDescription
idStringID of deployment
fileIdStringID of the file
callbackfunctionCallback will be called with (err, file)

now.getAliases(id OR callback, callback) ⇒ Promise

Returns an array with all aliases.

Kind: instance method of Now
See: https://zeit.co/api#user-aliases

ParamTypeDescription
id OR callbackString | functionID of deployment or callback
callbackfunctionCallback will be called with (err, aliases)

now.createAlias(id, alias, callback) ⇒ Promise

Creates an alias for the given deployment.

Kind: instance method of Now
See: https://zeit.co/api#create-alias

ParamTypeDescription
idStringID of deployment
aliasStringHostname or custom url for the alias
callbackfunctionCallback will be called with (err, data)

now.deleteAlias(id, callback) ⇒ Promise

Deletes an alias and returns a status.

Kind: instance method of Now
See: https://zeit.co/api#delete-user-aliases

ParamTypeDescription
idStringID of alias
callbackfunctionCallback will be called with (err, status)
0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago