-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.ts
48 lines (36 loc) · 1.17 KB
/
controller.ts
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
//auto importing .env
import "https://deno.land/x/dotenv/load.ts"
let oldName:string = 'This_Repo_has_3_issues_0_watchers'
const getRepoData = async ({response}:{response:any})=>{
const authKey:any = await Deno.env.get('AUTH_KEY');
let requestHeaders: any = {
'Authorization':`token ${authKey}`,
}
const url:string = `https://api.github.com/repos/avinashbharti97/${oldName}`;
let issues:any = 0;
let watchers:any = 0;
await fetch(url, {
headers: requestHeaders,
}).then(res => res.json()).then(data => {
issues = data["open_issues"];
watchers = data["watchers"];
console.log(issues)
})
let postHeaders: any = {
'Authorization':`token ${authKey}`,
'Content-Type':'application/json',
'Accept':'application/json'
}
let postBody:any = {
"name": `This_Repo_has_${issues}_issues_${watchers}_watchers`
// "name": "TEst"
}
await fetch(url, {
method:'POST',
headers: postHeaders,
body: JSON.stringify(postBody)
})
.then(oldName = postBody["name"]);
response.body = {"status":"success"}
}
export {getRepoData}