How to use do-wrapper - 6 common examples

To help you get started, we’ve selected a few do-wrapper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github satyarohith / shark / src / base / index.js View on Github external
async validateToken(token) {
    try {
      const api = new DigitalOcean(token);
      const {
        body: {account}
      } = await api.account();
      if (account.status === 'active') {
        return true;
      }

      return false;
    } catch (error) {
      console.error(error.message);
      process.exit(1);
    }
  }
github satyarohith / shark / util.js View on Github external
const verifyAccount = async accesstoken => {
    try {
      const DoAPI = new DigitalOcean(accesstoken, 5);
      spinner.start('Verifying your account...');
      const {
        body: { account }
      } = await DoAPI.account();

      if (account) {
        spinner.succeed('Account verified!');
        config.set('do_api_access_token', accesstoken);
        console.log(`
          ${chalk.green('Hi! Your access token is valid.')}
          Email: ${account.email}
          Droplet Limit: ${account.droplet_limit}
          Floating IP Limit: ${account.floating_ip_limit}
          `);
      }
    } catch (error) {
github satyarohith / shark / src / base / index.js View on Github external
async init() {
    let API_TOKEN = '';

    if (config.has('do_access_token')) {
      API_TOKEN = config.get('do_access_token');
    } else {
      const {askToken} = require('../prompts');
      const {token} = await askToken();
      await this.validateToken(token);
      this.setToken('do_access_token', token);
      API_TOKEN = token;
    }

    this.api = new DigitalOcean(API_TOKEN);
    this.spinner = new Ora();
  }
github satyarohith / shark / util.js View on Github external
'use strict';
const DigitalOcean = require('do-wrapper').default;
const chalk = require('chalk');
const CacheConf = require('cache-conf');
const Ora = require('ora');

const config = new CacheConf();
const spinner = new Ora();
const ACCESS_TOKEN = config.get('do_api_access_token');
const DoAPI = new DigitalOcean(ACCESS_TOKEN, 50);

module.exports.config = config;

module.exports.spinner = spinner;

module.exports.DoAPI = DoAPI;

module.exports.initAccount = async () => {
  const verifyAccount = async accesstoken => {
    try {
      const DoAPI = new DigitalOcean(accesstoken, 5);
      spinner.start('Verifying your account...');
      const {
        body: { account }
      } = await DoAPI.account();
github BekirUzun / SelfVPN / src / app / providers / vps-service / vps.service.ts View on Github external
constructor(public events: Events, public logs: LoggerService, public config: ConfigService) {
    let key = this.config.get(ConfigKeys.apiKey);
    this.api = new DigitalOcean(key);
  }
github BekirUzun / SelfVPN / src / app / providers / vps-service / vps.service.ts View on Github external
updateApiKey(key: string): Promise {
    let apiToCheck = new DigitalOcean(key);
    return apiToCheck.account().then((resp) => {
      if (resp.body.account.droplet_limit === 0) {
        throw new Error(errors.DROPLET_LIMIT);
      }
      this.api = apiToCheck;
    });
  }

do-wrapper

Node.js Wrapper for Digital Ocean API v2

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular do-wrapper functions