cdn_cache.js
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
*
* @author: chenfeng<feng.chen@yoho.cn>
* @date: 16/10/19
*/
'use strict';
const Router = require('koa-router');
const {
CdnCache
} = require('../../models');
const r = new Router();
const cdnCache = {
async query(ctx) {
let date = {
typeList: [{
name: '文件',
typeName: 'File',
}, {
name: '目录',
typeName: 'Directory',
}],
cloudList: [{
name: '腾讯云',
cloudName: 'qcloud',
}, {
name: '阿里云',
cloudName: 'aliyun',
}, {
name: '七牛云',
cloudName: 'qiniu'
}]
}
await ctx.render('action/cdn_cache', date);
},
async clear(ctx) {
let queryUris = ctx.request.body.query_uri;
let objectType = ctx.request.body.object_type;
let cloud = ctx.request.body.cloud || 'aliyun'; // aliyun or qcloud
if (queryUris.trim() && objectType) {
CdnCache.removeCache(queryUris, objectType, cloud);
}
return ctx.body = {
code: 200
};
}
}
r.get('/query', cdnCache.query);
r.post('/clear', cdnCache.clear);
module.exports = r;