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-client
const Now = require('now-client')
const 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((err, deployments) => {
if (err) {
console.error(err)
return
}
console.log(deployments)
})
Kind: global class
- Now
- new Now([token])
- .getDeployments([callback]) ⇒
Promise
- .getDeployment(id, [callback]) ⇒
Promise
- .createDeployment(body, [callback]) ⇒
Promise
- .deleteDeployment(id, [callback]) ⇒
Promise
- .getFiles(id, [callback]) ⇒
Promise
- .getFile(id, fileId, [callback]) ⇒
Promise
- .getAliases([id OR callback], [callback]) ⇒
Promise
- .createAlias(id, alias, [callback]) ⇒
Promise
- .deleteAlias(id, [callback]) ⇒
Promise
Initializes the API. Looks for token in ~/.now.json if none is provided.
Param | Type | Description |
---|---|---|
[token] | String |
Your now API token. |
Returns an array with all deployments.
Kind: instance method of Now
See: https://zeit.co/api#list-endpoint
Param | Type | Description |
---|---|---|
[callback] | function |
Callback will be called with (err, deployments) |
Returns an object with deployment data.
Kind: instance method of Now
See: https://zeit.co/api#get-endpoint
Param | Type | Description |
---|---|---|
id | String |
ID of deployment |
[callback] | function |
Callback will be called with (err, deployment) |
Creates a new deployment and returns its data.
Kind: instance method of Now
See: https://zeit.co/api#instant-endpoint
Param | Type | Description |
---|---|---|
body | Object |
Object a package key (for package.json data). The other keys should represent a file path, with their respective values containing the file contents. |
[callback] | function |
Callback will be called with (err, deployment) |
Deletes a deployment and returns its data.
Kind: instance method of Now
See: https://zeit.co/api#rm-endpoint
Param | Type | Description |
---|---|---|
id | String |
ID of deployment |
[callback] | function |
Callback will be called with (err, deployment) |
Returns an array with the file structure.
Kind: instance method of Now
See: https://zeit.co/api#file-structure-endpoint
Param | Type | Description |
---|---|---|
id | String |
ID of deployment |
[callback] | function |
Callback will be called with (err, fileStructure) |
Returns the content of a file.
Kind: instance method of Now
See: https://zeit.co/api#file--endpoint
Param | Type | Description |
---|---|---|
id | String |
ID of deployment |
fileId | String |
ID of the file |
[callback] | function |
Callback will be called with (err, file) |
Returns an array with all aliases.
Kind: instance method of Now
See: https://zeit.co/api#user-aliases
Param | Type | Description |
---|---|---|
[id OR callback] | String | function |
ID of deployment or callback |
[callback] | function |
Callback will be called with (err, aliases) |
Creates an alias for the given deployment.
Kind: instance method of Now
See: https://zeit.co/api#create-alias
Param | Type | Description |
---|---|---|
id | String |
ID of deployment |
alias | String |
Hostname or custom url for the alias |
[callback] | function |
Callback will be called with (err, data) |
Deletes an alias and returns a status.
Kind: instance method of Now
See: https://zeit.co/api#delete-user-aliases
Param | Type | Description |
---|---|---|
id | String |
ID of alias |
[callback] | function |
Callback will be called with (err, status) |