闪购盲盒互助环境变量为 JDSGMH_SHARECODES,修复圈x图标不存在。更新随机UA。

This commit is contained in:
lxk0301
2021-01-26 09:51:35 +08:00
20 changed files with 409 additions and 189 deletions

View File

@@ -11,7 +11,7 @@ const clientConfig = {
secretId: process.env.TENCENT_SECRET_ID,
secretKey: process.env.TENCENT_SECRET_KEY,
},
region: "ap-hongkong",
region: process.env.TENCENT_REGION, // 区域参考https://cloud.tencent.com/document/product/213/6091
profile: {
httpProfile: {
endpoint: "scf.tencentcloudapi.com",
@@ -20,9 +20,9 @@ const clientConfig = {
};
const client = new ScfClient(clientConfig);
const params = {
let params = {
"Handler": "index.main_handler",
"FunctionName": "jd",
"FunctionName": process.env.TENCENT_FUNCTION_NAME, // 云函数程序名,例如 jd_scripts
"ZipFile": contents_in_base64
};
client.UpdateFunctionCode(params).then(
@@ -33,3 +33,47 @@ client.UpdateFunctionCode(params).then(
console.error("error", err);
}
);
// 更新环境变量
let vars = []
for(let key in process.env){
vars.push({
"Key": key,
"Value": process.env[key]
})
}
params = {
"Environment": {
"Variables": vars
}
};
client.UpdateFunctionConfiguration(params).then(
(data) => {
console.log(data);
},
(err) => {
console.error("error", err);
}
);
// 更新触发器
const inputYML = 'serverless.yml';
const yaml = require('js-yaml');
const obj = yaml.load(fs.readFileSync(inputYML, {encoding: 'utf-8'}))
for(let vo of obj.inputs.events){
let param = {
'Type' : "timer",
'TriggerDesc' : vo.timer.parameters.cronExpression,
'CustomArgument' : vo.timer.parameters.argument,
'Enable' : "true"
}
client.CreateTrigger(param).then(
(data) => {
console.log(data);
},
(err) => {
console.error("error", err);
}
);
}