🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more
Socket
Book a DemoInstallSign in
Socket

@aird/sdk

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aird/sdk

AirDwing SDK

latest
Source
npmnpm
Version
1.1.6
Version published
Maintainers
1
Created
Source

安装

npm i --save @aird/sdk
# 或
yarn add @aird/sdk

支持方法

除get外,默认application/x-www-form-urlencoded

  • get
  • post
  • put
  • delete

使用

const SDK = require('@aird/sdk');

const sdk = new SDK({
  SecretId: 'xxxx',
  SecretKey: 'xxxx',
  // 访问的域名:
  // Domain: 'api.airdwing.com',
  // 是否启用HTTPS:
  // Secure: true, 
  // 自定义预处理方法
  // filter: x => x.data,
  // 自定义异常捕获方法
  // catch: (err) => { throw err; }
});

(async () => {
  const result = await sdk.get('/user/check', {
    username: '13212341234'
  });
  console.log(result);
})();

文件上传

需要稍微注意一下的接口:

const SDK = require('@aird/sdk');
const fs = require('fs');

const sdk = new SDK({
  SecretId: 'xxxx',
  SecretKey: 'xxxx'
});

(async () => {
  const result = await sdk.upload({
    auth: 'xxxx',
    type: 'orgverify',
    file: fs.createReadStream('PATH/TO/xxx.jpg') // 注意这里, 本地文件可以用 path.join 拼装地址,或者直接用Stream
  });
  console.log(result);
})();

无缝对接腾讯云接口

Demo:

const SDK = require('@aird/sdk');

const cvm = new SDK({
  SecretId: 'xxxx',
  SecretKey: 'xxxx',
  Domain: 'cvm.api.qcloud.com'
});

(async () => {
  const result = await cvm.get('/v2/index.php', {
    Action: 'DescribeInstances',
    Region: 'gz'
  });
  console.log(result);
})();

License

Apache 2.0

FAQs

Package last updated on 02 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts