now-universal-client
🎁 Promise-based Universal API wrapper for now.sh
Usage
$ npm install --save now-universal-client
const getDeployments = const TOKEN = 'YOUR TOKEN' let deployments try deployments = await catch err console console
API
const now =
Promise
now.getDeployments({token}) ⇒ Returns an array with all deployments.
Kind: instance method of Now
See: https://zeit.co/api#list-endpoint
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
Resolves to an array of deployments.
Promise
now.getDeployment({token, id}) ⇒ Returns an object with deployment data.
Kind: instance method of Now
See: https://zeit.co/api#get-endpoint
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID of deployment |
Resolves to the deployment object.
Promise
now.createDeployment({token, data}) ⇒ Creates a new deployment and returns its data.
Kind: instance method of Now
See: https://zeit.co/api#instant-endpoint
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
data | Object |
The keys should represent a file path, with their respective values containing the file contents. |
Resolves to the deployment object.
Promise
now.deleteDeployment({token, id}) ⇒ Deletes a deployment and returns its data.
Kind: instance method of Now
See: https://zeit.co/api#rm-endpoint
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID of deployment |
Resolves to the deployment object.
Promise
now.getFiles({token, id}) ⇒ Returns an array with the file structure.
Kind: instance method of Now
See: https://zeit.co/api#file-structure-endpoint
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID of deployment |
Resolves to an array with the file structure.
Promise
now.getFile({token, id, fileId}) ⇒ 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 |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID of deployment |
fileId | String |
ID of the file |
Resolves to either a String or an Object of the file's content.
Promise
now.getDomains({token}) ⇒ 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 |
---|---|---|
token | String |
Your ZEIT token |
Resolves to an array with all domain names and related aliases.
Promise
now.addDomain({token, domain}) ⇒ Adds a new domain and returns its data.
Kind: instance method of Now
See: https://zeit.co/api#post.domains
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
domain | object |
An object containing a string name and a boolean isExternalDNS |
Resolves to an object with the domain's data.
Promise
now.deleteDomain({token, name}) ⇒ Deletes a domain name.
Kind: instance method of Now
See: https://zeit.co/api#delete-domains
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
name | String |
Domain name |
Promise
now.getDomainRecords({token, domain}) ⇒ Returns an array with all DNS records configured for a domain name.
Kind: instance method of Now
See: https://zeit.co/api#get-domain-records
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
name | String |
Domain name |
Resolves to an array with all DNS records configured for a domain name.
Promise
now.addDomainRecord({token, domain, recordData}) ⇒ Adds a new DNS record for a domain.
Kind: instance method of Now
See: https://zeit.co/api#post-domain-records
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
domain | object |
An object containing a string name and a boolean isExternalDNS |
recordData | object |
An object containing a description of the new record according to the documentation. |
Promise
now.deleteDomainRecord({token, name, recordId}) ⇒ Deletes a DNS record associated with a domain.
Kind: instance method of Now
See: https://zeit.co/api#delete-domain-records
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
domain | String |
Domain name |
recordId | String |
Record ID |
Promise
now.getCertificates({token, [cn]}) ⇒ Returns an array of all certificates.
Kind: instance method of Now
See: https://zeit.co/api#get-certs
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
[cn] | String |
Common Name |
Resolves to an array of all certificates.
Promise
now.createCertificate({token, cn}) ⇒ 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 |
---|---|---|
token | String |
Your ZEIT token |
cn | String |
Common Name |
Promise
now.renewCertificate({token, cn}) ⇒ Renews an existing certificate.
Kind: instance method of Now
See: https://zeit.co/api#post-certs
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
cn | String |
Common Name |
Promise
now.replaceCertificate({token, cn, cert, key, [ca]}) ⇒ Replace an existing certificate.
Kind: instance method of Now
See: https://zeit.co/api#put-certs
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
cn | String |
Common Name |
cert | String |
X.509 certificate |
key | String |
Private key for the certificate |
ca | String |
CA certificate chain |
Resolves to an object with the new certificate details.
Promise
now.deleteCertificate({token, cn}) ⇒ Deletes a certificate.
Kind: instance method of Now
See: https://zeit.co/api#delete-certs
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
cn | String |
Common Name |
Promise
now.getAliases({token, [id]}) ⇒ Returns an array with all aliases.
Kind: instance method of Now
See: https://zeit.co/api#user-aliases
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
[id OR callback] | String | function |
ID of deployment or callback |
Resolves to an array with all aliases.
Promise
now.createAlias({token, id, alias}) ⇒ Creates an alias for the given deployment.
Kind: instance method of Now
See: https://zeit.co/api#create-alias
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID of deployment |
alias | String |
Hostname or custom url for the alias |
Resolves to an Object with the alias data
Promise
now.deleteAlias({token, id}) ⇒ Deletes an alias and returns a status.
Kind: instance method of Now
See: https://zeit.co/api#delete-user-aliases
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID of alias |
Resolves to the status
Promise
now.getSecrets({token, id}) ⇒ Returns an array with all secrets.
Kind: instance method of Now
See: https://zeit.co/api#get-now-secrets
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
[id OR callback] | String | function |
ID of deployment or callback |
Resolves to an array with all secrets.
Promise
now.createSecret({token, name, value}) ⇒ Creates a secret and returns its ID.
Kind: instance method of Now
See: https://zeit.co/api#post-now-secrets
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
name | String |
name for the secret |
value | String |
value for the secret |
Resolves to a secret's ID.
Promise
now.renameSecret({token, id, name}) ⇒ 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 |
---|---|---|
token | String |
Your ZEIT token |
id | String |
id or name of the secret |
name | String |
new name for the secret |
Resolves to a secret's ID and name.
Promise
now.deleteSecret({token, id}) ⇒ Deletes a secret and returns its ID.
Kind: instance method of Now
See: https://zeit.co/api#delete-now-secrets
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
id | String |
ID or name of the secret |
Resolves to a secret's status.
Promise
now.getEvents({token}) ⇒ Get the latest events happened in your team.
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
Resolves to an array of events.
Promise
now.getUser({token}) ⇒ Get the info of user with the provided token
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
Resolves to a user object.
Promise
now.getTeams({token}) ⇒ Get the teams that are related to the given token.
Param | Type | Description |
---|---|---|
token | String |
Your ZEIT token |
Resolves to an array of teams.
License
See License.