0.4.5 • Published 8 years ago

zeit-client-api v0.4.5

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

zeit-client-api

A library for easily sharing code among Zeit clients written in Javascript.

Zeit is a company making now() – which deploys Node.js cloud apps very easily. See zeit.co for more information about it.

Install for Node

npm install --save zeit-client-api
npm explore zeit-client-api -- npm run start node

Install for React Native

npm install --save zeit-client-api
npm explore zeit-client-api -- npm run start reactnative

Multiple platform support is included here because...

Universal / isomorphic apps are amazing! So this API is built so that it's easy to maintain going forward. To this end it generates the appropriate dependencies for each major platform. For example, if reactnative is requested then this will use React Native's fetch instead of node-fetch.

This library also relies on local storage to store the API token so you can reuse it later or easily discard it.

Usage

const Zeit = require('zeit-client-api');

Zeit.API.setToken(YOUR_ZEIT_TOKEN)
        .deployments()
        .then(console.log.bind(console))
        .catch(console.error);

API Examples

Once you call setToken() you don't need to call it again, btw. It just works because the token is in LocalStorage.

All methods return Promises.

Zeit.API.alias(DEPLOY_ID, HOST_OR_URL);
Zeit.API.aliases();
Zeit.API.deployments();
Zeit.API.deployment(DEPLOY_ID);
Zeit.API.deleteDeployment(DEPLOY_ID);
Zeit.API.files(DEPLOY_ID);
# A brief example of how to deploy to Zeit.
const DEPLOY_CONTENTS = {
    package: {
    name: DEPLOY_NAME,
    scripts: { start: 'node index' }
  },
  'index.js':
    'require("http").Server((req, res) => {' +
      'res.end("zeit-client-api-test");' +
    '}).listen();'
};
Zeit.API.deploy(DEPLOY_CONTENTS);

Testing

If you're using it as a module and want to run the tests, try this:

TOKEN=[token] npm explore zeit-client-api -- npm test

Tests only use the Node.JS shims for now.

License

Code released under the MIT license. © Contributors

0.4.5

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago