generated from bitprj/Intro-To-Serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.1.6.js
46 lines (37 loc) · 1.4 KB
/
test.1.6.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const fetch = require('node-fetch');
const args = require('minimist')(process.argv.slice(2))
const functions = require('./functions');
const user = args['user'];
const repo = args['repo'];
let uri = process.env.TWOCATZ_ENDPOINT
async function main() {
try {
functions.checkSecret(uri, "TWOCATZ_ENDPOINT")
//if you wanna add more files, just put a comma after the filename (array)
const commit_file = ['twocatz/index.js']
functions.checkCommit(commit_file)
const resp = await fetch(uri, {
method: 'GET'
});
var data = await resp.json()
let test = JSON.stringify(data)
functions.validateResponseStatus(resp, uri)
if (test.length < 3) {
console.error("No response... Try again!")
process.exit(1)
}
try {
var catimage = test;
var newCat = Buffer.from(catimage, 'base64').toString('ascii')
console.info("Yay! 🎉 We got your cat picture 🐱")
} catch (e) {
console.error("Sorry! We couldn't find one or both of the cat pictures. Make sure you encoded in BASE64!")
await functions.throwError("Sorry! We couldn't find one or both of the cat pictures. Make sure you encoded in BASE64!", user, repo)
process.exit(1)
}
}
catch (e) {
await functions.throwError(e, user, repo)
}
}
main();