npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@volcengine/imagex-openapi

v2.2.0

Published

火山引擎视频云 Nodejs SDK,提供完备的 OPENAPI 请求调用能力

Downloads

22

Readme

@volcengine/imagex-openapi

中文版

Documentation

The documentation for the Volcengine VCloud API can be found here

The documentation for the nodejs SDK API can be found here

The documentation for the Volcengine AK&SK can be found here

Versions

@volcengine/imagex-openapi uses a modified version of Semantic Versioning for all changes.

Supported Node.js Versions

This library supports Nodejs version 12 and above.

Sample Usage

Setting OpenAPI service's AK&SK

Available in three settings

1. By class initial options to set AK&SK


import VolcSdk from '@volcengine/imagex-openapi';

const client = new VolcSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey'
});

2. Use environment variables to set AK & SK

VOLC_ACCESSKEY="your ak" VOLC_SECRETKEY="your sk"

3. Use configuration file

Put it in ~/.volc/config in json format, the format is:

{"VOLC_ACCESSKEY":"your ak","VOLC_SECRETKEY":"your sk"}

Specify Region and/or Host

You could specify the target Region and/or Host for the client:

import VCloudSdk from '@volcengine/imagex-openapi';

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  region: 'cn-north-1',
  host: 'open.volcengineapi.com'
});

Logging and custom log

To log this SDK request, you could set the logLevel or set your own application log policy by setting LoggerOptions.log method.

import VCloudSdk from '@volcengine/imagex-openapi';
import winston from 'winston';

const appLogger = winston.createLogger();

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  loggerOptions: {
    level: 'debug',
    log: function(opts) {
      appLogger.log(opts);
    },
  },
});

Using a Custom HTTP Request Client

The Volcengine VCloud nodejs SDK uses axios, a promise-based HTTP client, to make requests. You can also provide your own httpClient to customize requests as needed.

import VCloudSdk from '@volcengine/imagex-openapi';
import customHttpRequest from './customHttpRequest';

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  region: 'cn-north-1',
  host: 'open.volcengineapi.com',
  httpRequest: customHttpRequest,
});

Write a custom HTTP client

async function request(url, options) {
  const { headers = {}, proxy, maxBodyLength = 0 } = options;
  const reqOption: AxiosRequestConfig = {
    url,
    ...options,
    headers: {
      ...headers,
      'User-Agent': 'your own user agent'
    }
  };
  try {
    const res = await axios(reqOption);
    return {status: res.status, body: res.data, headers: res.headers};
  } catch(e) {
    // report metrics and so on...
  }
}

Use a custom HTTP client with this SDK, you could mock the Volcengine API responses, and run your unit and integration tests quickly without the need to make a connection to Volcengine.

plugin

If the current features can't meet your needs, you can try to write a custom plugin following the next format

function plugin () {
  return async (context, next) => {
    // ...
    // execute before send request
    await next() // execute the rest plugins and send request at last
    // execute after send request
    // ...
  }
}

there is a simple example

export default function accessPlugin() {
    return async (context, next) => {
        if(checkAccess()) {
          await next();
        } else {
          context.response = 'has no access';
        }
        return;
    };
}

then you need to register this plugin to a client

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey',
  region: 'cn-north-1',
  host: 'open.volcengineapi.com',
  httpRequest: customHttpRequest,
});
client.addPlugin(accessPlugin);

Proxy Settings

To make request via a proxy host, you could set the proxy options.

1. By class initial options to set proxy

import VCloudSdk from '@volcengine/imagex-openapi';

const client = new VCloudSdk({
  accessKey: 'your own accessKey',
  secretKey: 'your own secretKey', 
  proxy: {
      protocol: 'https',
      host: 'your own proxy host ip',
      auth: 'your own proxy host auth',
      port: 8080, // your own proxy host port
  }
});

2.Use environment variables to set proxy.

VOLC_PROXY_HOST="your own proxy host" VOLC_PROXY_PORT="your own proxy host port"

Getting help

If you need help installing or using the sdk, please check the Volcengine Support Help Center first.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!