New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@axolo/egg-tencent-cloud

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axolo/egg-tencent-cloud

Tencent Cloud SDK 4.x plugin for Egg.js.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

egg-tencent-cloud

Tencent Cloud SDK 4.x plugin for Egg.js.

Install

npm i @axolo/egg-tencent-cloud --save

Usage

// {app_root}/config/plugin.js
exports.tencentCloud = {
  enable: true,
  package: '@axolo/egg-tencent-cloud',
};

Configuration

see config/config.default.js for more detail. for example:

// {app_root}/config/config.default.js
exports.tencentCloud = {
  client: {
    // tencentCloud, // tencentcloud-sdk-nodejs user-defined
    // region: 'ap-guangzhou',
    // reqMethod: 'POST',
    // reqTimeout: 60,
    // signMethod: 'HmacSHA256',
    secretId: 'SECRET_ID',
    secretKey: 'SECRETK_EY',
    model: 'sms',
    version: 'v20190711',
    action: 'SendStatusStatistics',
    params: {
      SmsSdkAppid: 'SMS_SDK_APPID',
      Limit: 0,
      Offset: 0,
    },
};

API

client

the member of Tencent Cloud SDK Model client. usage like:

'use strict';

const Controller = require('egg').Controller;

class TencentCloudController extends Controller {
  async index() {
    const { app, ctx } = this;
    const smsCount = app.tencentCloud.get('smsCount');
    const result = await smsCount.client.SmsPackagesStatistics({
      ...smsCount.options.params,
      Limit: 10,
    });
    ctx.body = result;
  }
}

module.exports = TencentCloudController;

action(params)

params

paramstypedescription
paramsobjectparams of Tencent Cloud SDK Action

return

a Promise of Tencent Cloud SDK Model client Action response.

Example

'use strict';

const dayjs = require('dayjs');
const Controller = require('egg').Controller;

class TencentCloudController extends Controller {
  async index() {
    const { app, ctx } = this;
    const smsCount = app.tencentCloud.get('smsCount');
    const now = dayjs();
    const lastMonth = now.subtract(1, 'months');
    const StartDateTime = lastMonth.format('YYYYMMDDhh');
    const EndDataTime = now.format('YYYYMMDDhh');
    const result = await smsCount.action({ StartDateTime, EndDataTime });
    ctx.body = result;
  }
}

module.exports = TencentCloudController;

Questions & Suggestions

Please open an issue here.

License

MIT

Keywords

egg

FAQs

Package last updated on 15 Apr 2021

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