Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
NLP_ID,
NLP_SECRET
} from '../config'
import { wechatContentCheck, wechatImgCheck } from '../utils'
import Promise from 'Promise'
const tencentcloud = require('tencentcloud-sdk-nodejs')
const NlpClient = tencentcloud.nlp.v20190408.Client
const models = tencentcloud.nlp.v20190408.Models
const Credential = tencentcloud.common.Credential
const ClientProfile = tencentcloud.common.ClientProfile
const HttpProfile = tencentcloud.common.HttpProfile
const router = express.Router()
/* notes/publish
* 该接口弃用,仅用于兼容2.0.8以下版本(20180726)
*/
router.post('/publish', (req, res) => {
const {
uid,
token,
timestamp,
title,
content,
location,
longitude,
const {
rp,
sign
} = require('./utils');
const urlUtil = require('url');
const randomInt = require('random-int');
const config = require('./config');
const ERR = require('./error');
// 部分接口陆续使用 API 3.0
const tencentcloud = require('tencentcloud-sdk-nodejs');
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
class BaseService {
constructor({ AppId, SecretId, SecretKey } = {}) {
let {
APPID,
SECRETID,
SECRETKEY,
TENCENTCLOUD_APPID,
TENCENTCLOUD_SECRETID,
TENCENTCLOUD_SECRETKEY
} = process.env;
this.rp = rp;
this.AppId = AppId || TENCENTCLOUD_APPID || APPID;
this.SecretId = SecretId || TENCENTCLOUD_SECRETID || SECRETID;
const t = async function (englishText) {
const tencentcloud = require('tencentcloud-sdk-nodejs');
const TmtClient = tencentcloud.tmt.v20180321.Client;
const models = tencentcloud.tmt.v20180321.Models;
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
let cred = new Credential(
"AKIDcAEB4ous9MYv5ZhFm5c0XdfwzoX4FDtp",
"wgC9vVtBFC1PdHIDzmNjcKvHSN2XLyQh"
);
let httpProfile = new HttpProfile();
httpProfile.endpoint = "tmt.tencentcloudapi.com";
let clientProfile = new ClientProfile();
clientProfile.httpProfile = httpProfile;
let client = new TmtClient(cred, "ap-guangzhou", clientProfile);
let req = new models.TextTranslateRequest();
let params = '{"SourceText":"'+ englishText +'","Source":"en","Target":"zh","ProjectId":0}'
req.from_json_string(params);
return new Promise((resolve, reject) => {
async function sendSms(phone, code) {
const SmsClient = tencentcloud.sms.v20190711.Client;
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
const secretId = process.env.TENCENTCLOUD_SECRETID;
const secretKey = process.env.TENCENTCLOUD_SECRETKEY;
const token = process.env.TENCENTCLOUD_SESSIONTOKEN;
let cred = new Credential(secretId, secretKey, token);
let httpProfile = new HttpProfile();
httpProfile.endpoint = "sms.tencentcloudapi.com";
let clientProfile = new ClientProfile();
clientProfile.httpProfile = httpProfile;
let client = new SmsClient(cred, "ap-guangzhou", clientProfile);
let req = {
PhoneNumberSet: ["+" + phone], //大陆手机号861856624****
TemplateID: process.env.SMS_TEMPLATE_ID, //腾讯云短信模板id
Sign: process.env.SMS_SIGN, //腾讯云短信签名
export function callCloudApi(secretId, secretKey) {
const CvmClient = tencentcloud.cvm.v20170312.Client;
const models = tencentcloud.cvm.v20170312.Models;
const Credential = tencentcloud.common.Credential;
let cred = new Credential(secretId, secretKey);
let client = new CvmClient(cred, "ap-shanghai");
let req = new models.DescribeZonesRequest();
return new Promise((resolve, reject) => {
client.DescribeZones(req, function (err, response) {
if (err) {
reject(err)
return;
}
resolve(response)
});
})
}
function callCloudApi(secretId, secretKey) {
const CvmClient = tencentcloud.cvm.v20170312.Client;
const models = tencentcloud.cvm.v20170312.Models;
const Credential = tencentcloud.common.Credential;
let cred = new Credential(secretId, secretKey);
let client = new CvmClient(cred, 'ap-shanghai');
let req = new models.DescribeZonesRequest();
return new Promise((resolve, reject) => {
client.DescribeZones(req, function (err, response) {
if (err) {
reject(err);
return;
}
resolve(response);
});
});
}
exports.callCloudApi = callCloudApi;
async function sendSms(phone, code) {
const SmsClient = tencentcloud.sms.v20190711.Client;
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
const secretId = process.env.TENCENTCLOUD_SECRETID;
const secretKey = process.env.TENCENTCLOUD_SECRETKEY;
const token = process.env.TENCENTCLOUD_SESSIONTOKEN;
let cred = new Credential(secretId, secretKey, token);
let httpProfile = new HttpProfile();
httpProfile.endpoint = "sms.tencentcloudapi.com";
let clientProfile = new ClientProfile();
clientProfile.httpProfile = httpProfile;
let client = new SmsClient(cred, "ap-guangzhou", clientProfile);
let req = {
PhoneNumberSet: ["+" + phone], //大陆手机号861856624****
TemplateID: process.env.SMS_TEMPLATE_ID, //腾讯云短信模板id
Sign: process.env.SMS_SIGN, //腾讯云短信签名
TemplateParamSet: [code],