@begin/api
Advanced tools
Comparing version 1.8.0-RC.0 to 1.8.0
{ | ||
"name": "@begin/api", | ||
"version": "1.8.0-RC.0", | ||
"version": "1.8.0", | ||
"description": "Node.js client for api.begin.com", | ||
@@ -17,4 +17,3 @@ "type": "module", | ||
"lint": "eslint src --ext .js,.cjs,.mjs --fix", | ||
"test": "npm run lint && tape test/*-test.*js | tap-arc", | ||
"rc": "npm version prerelease --preid RC" | ||
"test": "npm run lint && tape test/*-test.*js | tap-arc" | ||
}, | ||
@@ -21,0 +20,0 @@ "repository": { |
@@ -1,4 +0,4 @@ | ||
> Node client for api.begin.com | ||
> Node.js client for api.begin.com | ||
Obtain an `token` by creating a client at https://api.begin.com. | ||
Obtain a `token` by logging in at https://begin.com, or by creating a client at https://api.begin.com. | ||
@@ -13,92 +13,11 @@ # Install | ||
## ESM | ||
```js | ||
// ESM | ||
import begin from '@begin/client' | ||
```javascript | ||
import { App } from '@begin/api' | ||
``` | ||
// CJS | ||
const begin = require('@begin/client') | ||
## CJS | ||
```javascript | ||
const { App } = require('@begin/api') | ||
// Method example (list all apps for token) | ||
const apps = await begin.list({ token }) | ||
``` | ||
### App static methods | ||
```javascript | ||
// list apps | ||
let { apps } = await App.list() | ||
// find an app by id | ||
let app = await App.find({ access_token, appID }) | ||
// list regions available to create a new app with | ||
let app = await App.regions({ access_token, zip }) | ||
// create a new app | ||
let app = await App.create({ access_token, zip }) | ||
// create a new app using @begin/chunker | ||
let app = await App.create({ access_token, chunk, zip }) | ||
``` | ||
### App instance methods | ||
```javascript | ||
// read app logs | ||
let logs = await App.logs() | ||
// read build logs | ||
let logs = await App.builds() | ||
// deploy a new version of the app | ||
await App.deploy({ zip }) | ||
// deploy a new version of the app using @begin/chunker | ||
await App.deploy({ chunk, zip }) | ||
// destroy an app | ||
await App.destroy() | ||
``` | ||
### Work with environment variables | ||
```javascript | ||
// get the app env | ||
let { env } = await App.env.get() | ||
// write an env var | ||
await App.env.set({ key: "HENLO", value: "world" }) | ||
// remove an env var | ||
await App.env.destroy({ key: "HENLO" }) | ||
``` | ||
### Work with static assets | ||
```javascript | ||
// get the app env | ||
let { files } = await App.static.get() | ||
// write a file | ||
let body = Buffer.from('console.log("hi")').toString('base64') | ||
await App.static.set({ name: '/file.js', body }) | ||
// remove the file | ||
await App.static.destroy({ name: '/file.js' }) | ||
``` | ||
# Contributing | ||
Create `.env` with the following values: | ||
```bash | ||
BEGIN_CLIENT_ID=xxx | ||
ACCESS_TOKEN=xxx | ||
# __BEGIN_TEST_URL__=localhost:3333 | ||
``` |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
25150
373
23