-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (43 loc) · 1.32 KB
/
index.js
File metadata and controls
50 lines (43 loc) · 1.32 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
const yaml = require('js-yaml');
const request = require('request-promise-native');
const AWS = require('aws-sdk');
const CDN = new AWS.S3();
exports.handler = async (event,context,callback) => {
const rawBlacklist = await request("https://raw.githubusercontent.com/CryptoScamDB/blacklist/master/data/urls.yaml");
const rawWhitelist = await request("https://raw.githubusercontent.com/CryptoScamDB/whitelist/master/data/urls.yaml");
const blacklist = yaml.safeLoad(rawBlacklist);
const whitelist = yaml.safeLoad(rawWhitelist);
await CDN.putObject({
Bucket: "cdn.cryptoscamdb.org",
Key: "blacklist/urls.yaml",
Body: rawBlacklist,
ContentType: "text/yaml"
}).promise();
await CDN.putObject({
Bucket: "cdn.cryptoscamdb.org",
Key: "blacklist/urls.json",
Body: JSON.stringify(blacklist,null,4),
ContentType: "application/json"
}).promise();
await CDN.putObject({
Bucket: "cdn.cryptoscamdb.org",
Key: "whitelist/urls.yaml",
Body: rawWhitelist,
ContentType: "text/yaml"
}).promise();
await CDN.putObject({
Bucket: "cdn.cryptoscamdb.org",
Key: "whitelist/urls.json",
Body: JSON.stringify(whitelist,null,4),
ContentType: "application/json"
}).promise();
callback(null,{
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*'
},
body: JSON.stringify({
success: true
})
});
};