tencentcloud-edgeone-migration-nodejs-v2
Version:
tencentcloud cdn config copy to edgeone
73 lines (69 loc) • 1.97 kB
JavaScript
const { t } = require("../../i18n/trans");
const genLog = require("../../logGenerator");
function Compression(domain, domainConfig, ruleTransferLog) {
const keyConfig = domainConfig.Compression;
if (!keyConfig || !keyConfig.CompressionRules || !keyConfig.CompressionRules.length || keyConfig.Switch !== 'on') {
ruleTransferLog.push({
config: t('智能压缩配置(Compression)'),
result: t('未配置'),
detail: ''
});
genLog.defaultLog(`${t('智能压缩配置(Compression)')}${t('未配置')}`)
return null;
}
const { CompressionRules } = keyConfig;
if (CompressionRules.find(rule => {
return rule.RuleType !== 'all';
})) {
ruleTransferLog.push({
config: t('智能压缩配置(Compression)'),
result: t('失败'),
detail: t(`规则引擎中,智能压缩不支持按照文件后缀或 Content-Type 配置; `)
});
genLog.warnLog(t(`规则引擎中,智能压缩不支持按照文件后缀或 Content-Type 配置; `));
return null;
}
ruleTransferLog.push({
config: t('智能压缩配置(Compression)'),
result: t('成功'),
detail: ''
});
genLog.successLog(`${t('智能压缩配置(Compression)')}${t('成功')}`)
return {
'Rules': [{
'Conditions': [
{
'Conditions': [
{
'Operator': 'equal',
'Target': 'host',
'Values': [
'all'
]
}
]
}
],
'Actions': [
{
'NormalAction': {
'Action': 'Compression',
'Parameters': [
{
'Name': 'Switch',
'Values': [
'on'
]
},
{
'Name': 'Algorithms',
'Values': CompressionRules[0].Algorithms
}
]
}
}
]
}]
};
}
module.exports = Compression;