An open API service indexing awesome lists of open source software.

https://github.com/mathdroid/now-universal-client

🎁 Universal API wrapper for now.sh
https://github.com/mathdroid/now-universal-client

Last synced: 9 months ago
JSON representation

🎁 Universal API wrapper for now.sh

Awesome Lists containing this project

README

          

# now-universal-client

> 🎁 Promise-based Universal API wrapper for now.sh

## Usage

```sh
$ npm install --save now-universal-client
```

```js
const {getDeployments} = require('now-universal-client')
const TOKEN = 'YOUR TOKEN'

let deployments

try {
deployments = await getDeployments({token: TOKEN})
} catch (err) {
console.error(err)
}

console.log(deployments)
```

## API

```js
const now = require('now-universal-client')
```

### now.getDeployments({token}) ⇒ Promise
Returns an array with all deployments.

**Kind**: instance method of [Now](#Now)
**See**: https://zeit.co/api#list-endpoint

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |

Resolves to an array of deployments.

### now.getDeployment({token, id}) ⇒ Promise
Returns an object with deployment data.

**Kind**: instance method of [Now](#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.

### now.createDeployment({token, data}) ⇒ Promise
Creates a new deployment and returns its data.

**Kind**: instance method of [Now](#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.

### now.deleteDeployment({token, id}) ⇒ Promise
Deletes a deployment and returns its data.

**Kind**: instance method of [Now](#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.

### now.getFiles({token, id}) ⇒ Promise
Returns an array with the file structure.

**Kind**: instance method of [Now](#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.

### now.getFile({token, id, fileId}) ⇒ Promise
Returns the content of a file either as string or object, depending on the filetype.

**Kind**: instance method of [Now](#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.

## now.getDomains({token}) ⇒ Promise
Returns an array with all domain names and related aliases.

**Kind**: instance method of [Now](#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.

## now.addDomain({token, domain}) ⇒ Promise
Adds a new domain and returns its data.

**Kind**: instance method of [Now](#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.

## now.deleteDomain({token, name}) ⇒ Promise
Deletes a domain name.

**Kind**: instance method of [Now](#Now)
**See**: https://zeit.co/api#delete-domains

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |
| name | String | Domain name |

## now.getDomainRecords({token, domain}) ⇒ Promise
Returns an array with all DNS records configured for a domain name.

**Kind**: instance method of [Now](#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.

## now.addDomainRecord({token, domain, recordData}) ⇒ Promise
Adds a new DNS record for a domain.

**Kind**: instance method of [Now](#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](https://zeit.co/api#post-domain-records). |

## now.deleteDomainRecord({token, name, recordId}) ⇒ Promise
Deletes a DNS record associated with a domain.

**Kind**: instance method of [Now](#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 |

## now.getCertificates({token, [cn]}) ⇒ Promise
Returns an array of all certificates.

**Kind**: instance method of [Now](#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.

## now.createCertificate({token, cn}) ⇒ Promise
Creates a new certificate for a domain registered to the user.

**Kind**: instance method of [Now](#Now)
**See**: https://zeit.co/api#post-certs

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |
| cn | String | Common Name |

## now.renewCertificate({token, cn}) ⇒ Promise
Renews an existing certificate.

**Kind**: instance method of [Now](#Now)
**See**: https://zeit.co/api#post-certs

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |
| cn | String | Common Name |

## now.replaceCertificate({token, cn, cert, key, [ca]}) ⇒ Promise
Replace an existing certificate.

**Kind**: instance method of [Now](#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.

## now.deleteCertificate({token, cn}) ⇒ Promise
Deletes a certificate.

**Kind**: instance method of [Now](#Now)
**See**: https://zeit.co/api#delete-certs

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |
| cn | String | Common Name |

### now.getAliases({token, [id]}) ⇒ Promise
Returns an array with all aliases.

**Kind**: instance method of [Now](#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.

### now.createAlias({token, id, alias}) ⇒ Promise
Creates an alias for the given deployment.

**Kind**: instance method of [Now](#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

### now.deleteAlias({token, id}) ⇒ Promise
Deletes an alias and returns a status.

**Kind**: instance method of [Now](#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

### now.getSecrets({token, id}) ⇒ Promise
Returns an array with all secrets.

**Kind**: instance method of [Now](#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.

### now.createSecret({token, name, value}) ⇒ Promise
Creates a secret and returns its ID.

**Kind**: instance method of [Now](#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.

### now.renameSecret({token, id, name}) ⇒ Promise
Changes the name of the given secret and returns its ID and name.

**Kind**: instance method of [Now](#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.

### now.deleteSecret({token, id}) ⇒ Promise
Deletes a secret and returns its ID.

**Kind**: instance method of [Now](#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.

### now.getEvents({token}) ⇒ Promise
Get the latest events happened in your team.

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |

Resolves to an array of events.

### now.getUser({token}) ⇒ Promise
Get the info of user with the provided token

| Param | Type | Description |
| --- | --- | --- |
| token | String | Your ZEIT token |

Resolves to a user object.

### now.getTeams({token}) ⇒ Promise
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](./LICENSE).