-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
81 lines (69 loc) · 1.83 KB
/
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
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const express = require("express")
const cors = require("cors")
const fetch = require("node-fetch")
const app = express()
const port = 3001
app.use(cors())
app.use(express.static("docs"))
app.get("/ping", (req, res) => {
res.send("pong")
})
const fetchUsers = async (userList) => {
let options = {
method: "GET",
mode: "cors",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer AAAAAAAAAAAAAAAAAAAAAM9qlAEAAAAAxWm8TUcXFxIlDNxGMsmwKsESbPU%3D3Jle5yAVKvSD0MS9QgRRpXGf9CYpn5pChjmYELa2a5FfuHSAjL",
},
}
const users = await Promise.all(userList.map((user) => fetch(`https://api.twitter.com/2/users/by/username/${user}?user.fields=profile_image_url,url`, options)))
.then((response) => {
return Promise.all(response.map((resp) => resp.json()))
})
.then((data) => {
return data
})
.catch((err) => {
console.log(err)
})
return users
}
app.get("/collabs", async (req, res) => {
const users = ["SaanhoiClub", "GoatSquadNFT", "D_CryptoFamily"]
const collabs = await fetchUsers(users)
res.status(200).json({ message: "collabs", collabs })
})
app.get("/hosts", async (req, res) => {
const users = [
"SteveRyanOnline",
"SkurpySocial",
"KoKid951",
"doodlegenics",
"Famous_Dyl",
"s0meone_U_Know",
"TheVoiceOfCash",
// "Wedripz.eth",
"GorillaMansion",
"DDish123",
"PuffPandas",
"LegendQueenWeb3",
"stukwan",
"EnvelopeCityInk",
"StrokeDriven",
"JuicyXBrat",
// "BTBD_ImDiDi",
"AunySIllyMe",
"Cheeeebz",
"ZongKia",
]
const hosts = await fetchUsers(users)
res.status(200).json({ message: "hosts", hosts })
})
app.get("/", (req, res) => {
res.send("Hello Griffin!")
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})