forked from wudongdefeng/jd-temporary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (25 loc) · 913 Bytes
/
index.js
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
//'use strict';
exports.main_handler = async (event, context, callback) => {
try {
const SOURCE_URL = process.env.SOURCE_URL
for (const v of event["Message"].split("&")) {
console.log(v);
if (SOURCE_URL) { //不允许直链!!!不允许直链!!!不允许直链!!!
const request = require('request')
console.log(`${SOURCE_URL}${v}.js`)
request(`${SOURCE_URL}${v}.js`, function(error, response, body) {
if (error){
console.log(error)
}else{
eval(response.body)
}
})
} else {
delete require.cache[require.resolve('./' + v + '.js')];
require('./' + v + '.js')
}
}
} catch (e) {
console.error(e)
}
}