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
Here are a few snippets on how to use this package in your project:
import nowClient from 'now-client'
const now = nowClient('YOUR TOKEN')
let deployments
try {
deployments = await now.getDeployments()
} catch (err) {
console.error(err)
}
console.log(deployments)
const nowClient = require('now-client')
const now = nowClient('YOUR TOKEN')
// Supports Promises
now.getDeployments().then(deployments => {
console.log(deployments)
}).catch(err => {
console.error(err)
})
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
- .getDomains([callback]) ⇒
Promise
- .addDomain(domain, [callback]) ⇒
Promise
- .deleteDomain(name, [callback]) ⇒
Promise
- .getCertificates([cn], [callback]) ⇒
Promise
- .createCertificate(cn, [callback]) ⇒
Promise
- .renewCertificate(cn, [callback]) ⇒
Promise
- .replaceCertificate(cn, cert, key, [ca], [callback]) ⇒
Promise
- .deleteCertificate(cn, [callback]) ⇒
Promise
- .getAliases([id OR callback], [callback]) ⇒
Promise
- .createAlias(id, alias, [callback]) ⇒
Promise
- .deleteAlias(id, [callback]) ⇒
Promise
- .getSecrets([id OR callback], [callback]) ⇒
Promise
- .createSecret(name, value, [callback]) ⇒
Promise
- .renameSecret(id, name, [callback]) ⇒
Promise
- .deleteSecret(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 |
The 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 either as string or object, depending on the filetype.
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, fileContent) |
Returns an array with all domain names and related aliases.
Kind: instance method of Now
See: https://zeit.co/api#get-domains
Param | Type | Description |
---|---|---|
[callback] | function |
Callback will be called with (err, domains) |
Adds a new domain and returns its data.
Kind: instance method of Now
See: https://zeit.co/api#post.domains
Param | Type | Description |
---|---|---|
domain | object |
An object containing a string name and a boolean isExternalDNS |
[callback] | function |
Callback will be called with (err) |
Deletes a domain name.
Kind: instance method of Now
See: https://zeit.co/api#delete-domains
Param | Type | Description |
---|---|---|
name | String |
Domain name |
[callback] | function |
Callback will be called with (err) |
Returns an array of all certificates.
Returns an array of all certificates.
Kind: instance method of Now
See: https://zeit.co/api#get-certs
Param | Type | Description |
---|---|---|
[cn] | String |
Common Name |
[callback] | function |
Callback will be called with (err, certs) |
Creates a new certificate for a domain registered to the user.
Kind: instance method of Now
See: https://zeit.co/api#post-certs
Param | Type | Description |
---|---|---|
cn | String |
Common Name |
[callback] | function |
Callback will be called with (err) |
Renews an existing certificate.
Kind: instance method of Now
See: https://zeit.co/api#post-certs
Param | Type | Description |
---|---|---|
cn | String |
Common Name |
[callback] | function |
Callback will be called with (err) |
Replace an existing certificate.
Kind: instance method of Now
See: https://zeit.co/api#put-certs
Param | Type | Description |
---|---|---|
cn | String |
Common Name |
cert | String |
X.509 certificate |
key | String |
Private key for the certificate |
ca | String |
CA certificate chain |
[callback] | function |
Callback will be called with (err, created) |
Deletes a certificate.
Kind: instance method of Now
See: https://zeit.co/api#delete-certs
Param | Type | Description |
---|---|---|
cn | String |
Common Name |
[callback] | function |
Callback will be called with (err) |
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) |
Returns an array with all secrets.
Kind: instance method of Now
See: https://zeit.co/api#get-now-secrets
Param | Type | Description |
---|---|---|
[id OR callback] | String | function |
ID of deployment or callback |
[callback] | function |
Callback will be called with (err, secrets) |
Creates a secret and returns its ID.
Kind: instance method of Now
See: https://zeit.co/api#post-now-secrets
Param | Type | Description |
---|---|---|
name | String |
name for the secret |
value | String |
value for the secret |
[callback] | function |
Callback will be called with (err, data) |
Changes the name of the given secret and returns its ID and name.
Kind: instance method of Now
See: https://zeit.co/api#patch-now-secrets
Param | Type | Description |
---|---|---|
id | String |
id or name of the secret |
name | String |
new name for the secret |
[callback] | function |
Callback will be called with (err, data) |
Deletes a secret and returns its ID.
Kind: instance method of Now
See: https://zeit.co/api#delete-now-secrets
Param | Type | Description |
---|---|---|
id | String |
ID or name of the secret |
[callback] | function |
Callback will be called with (err, status) |