tldraw/apps/www/utils/isSponsoringMe.ts
Steve Ruiz cd48b67a74
[chore] Sponsors in README (#301)
* Add images, read me links

* Add API route for sponsor image

* Update cache max age
2021-11-19 12:59:08 +00:00

24 lines
611 B
TypeScript

const whitelist = ['steveruizok']
export async function isSponsoringMe(login: string) {
if (whitelist.includes(login)) return true
const res = await fetch('https://api.github.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'bearer ' + process.env.GITHUB_API_SECRET,
},
body: JSON.stringify({
query: `
query {
user(login: "steveruizok") {
isSponsoredBy(accountLogin: "${login}")
}
}
`,
}),
}).then((res) => res.json())
return res?.data?.user?.isSponsoredBy
}