Skip to content

Commit 117169a

Browse files
committed
fix: use public GitHub sponsors query
1 parent f8c2b89 commit 117169a

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Welcome to TanStack.com!
22

3-
This site is built with TanStack Router!
3+
This site is built with TanStack Start and TanStack Router.
44

55
- [TanStack Router Docs](https://tanstack.com/router)
66

src/server/sponsors.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function getSponsors() {
8989

9090
sponsors.sort(
9191
(a, b) =>
92-
(b.amount || 0) - (a.amount || 0) || (b.createdAt > a.createdAt ? -1 : 1),
92+
(b.amount || 0) - (a.amount || 0) || a.login.localeCompare(b.login),
9393
)
9494

9595
return sponsors
@@ -103,28 +103,28 @@ async function getGithubSponsors() {
103103
`
104104
query ($cursor: String) {
105105
viewer {
106-
sponsorshipsAsMaintainer(first: 100, after: $cursor, includePrivate: true) {
106+
sponsorshipsAsMaintainer(first: 100, after: $cursor, includePrivate: false) {
107107
pageInfo {
108108
hasNextPage
109109
endCursor
110110
}
111111
edges {
112112
node {
113-
createdAt
114113
sponsorEntity {
115114
... on User {
115+
avatarUrl
116116
name
117117
login
118118
}
119119
... on Organization {
120+
avatarUrl
120121
name
121122
login
122123
}
123124
}
124125
tier {
125126
monthlyPriceInDollars
126127
}
127-
privacyLevel
128128
}
129129
}
130130
}
@@ -138,15 +138,14 @@ async function getGithubSponsors() {
138138

139139
type SponsorshipEdge = {
140140
node: {
141-
createdAt: string
142141
sponsorEntity: {
142+
avatarUrl: string
143143
name: string
144144
login: string
145145
} | null
146146
tier: {
147147
monthlyPriceInDollars: number
148148
} | null
149-
privacyLevel: string
150149
}
151150
}
152151

@@ -174,22 +173,22 @@ async function getGithubSponsors() {
174173
const mapped = edges
175174
.map((edge) => {
176175
const {
177-
node: { createdAt, sponsorEntity, tier, privacyLevel },
176+
node: { sponsorEntity, tier },
178177
} = edge
179178

180179
if (!sponsorEntity) {
181180
return null
182181
}
183182

184-
const { name, login } = sponsorEntity
183+
const { avatarUrl, name, login } = sponsorEntity
185184

186185
return {
187186
name,
188187
login,
189188
amount: tier?.monthlyPriceInDollars || 0,
190-
createdAt,
191-
private: privacyLevel === 'PRIVATE',
192-
imageUrl: '',
189+
createdAt: '',
190+
private: false,
191+
imageUrl: avatarUrl,
193192
linkUrl: '',
194193
}
195194
})
@@ -235,8 +234,10 @@ async function getGithubSponsors() {
235234
console.error('GitHub rate limit exceeded, returning empty sponsors.')
236235
return []
237236
}
238-
throw err
237+
console.error('Failed to fetch GitHub sponsors', err)
239238
}
239+
240+
return sponsors
240241
}
241242

242243
async function getSponsorsMeta(): Promise<SponsorMeta[]> {

src/utils/sponsors.functions.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async function getSponsors() {
9494

9595
sponsors.sort(
9696
(a, b) =>
97-
(b.amount || 0) - (a.amount || 0) || (b.createdAt > a.createdAt ? -1 : 1),
97+
(b.amount || 0) - (a.amount || 0) || a.login.localeCompare(b.login),
9898
)
9999

100100
return sponsors
@@ -109,14 +109,13 @@ async function getGithubSponsors() {
109109
`
110110
query ($cursor: String) {
111111
viewer {
112-
sponsorshipsAsMaintainer(first: 100, after: $cursor, includePrivate: true) {
112+
sponsorshipsAsMaintainer(first: 100, after: $cursor, includePrivate: false) {
113113
pageInfo {
114114
hasNextPage
115115
endCursor
116116
}
117117
edges {
118118
node {
119-
createdAt
120119
sponsorEntity {
121120
... on User {
122121
avatarUrl
@@ -132,7 +131,6 @@ async function getGithubSponsors() {
132131
tier {
133132
monthlyPriceInDollars
134133
}
135-
privacyLevel
136134
}
137135
}
138136
}
@@ -146,7 +144,6 @@ async function getGithubSponsors() {
146144

147145
type SponsorshipEdge = {
148146
node: {
149-
createdAt: string
150147
sponsorEntity: {
151148
avatarUrl: string
152149
name: string
@@ -155,7 +152,6 @@ async function getGithubSponsors() {
155152
tier: {
156153
monthlyPriceInDollars: number
157154
} | null
158-
privacyLevel: string
159155
}
160156
}
161157

@@ -183,7 +179,7 @@ async function getGithubSponsors() {
183179
const mapped = edges
184180
.map((edge) => {
185181
const {
186-
node: { createdAt, sponsorEntity, tier, privacyLevel },
182+
node: { sponsorEntity, tier },
187183
} = edge
188184

189185
if (!sponsorEntity) {
@@ -196,8 +192,8 @@ async function getGithubSponsors() {
196192
name,
197193
login,
198194
amount: tier?.monthlyPriceInDollars || 0,
199-
createdAt,
200-
private: privacyLevel === 'PRIVATE',
195+
createdAt: '',
196+
private: false,
201197
imageUrl: avatarUrl,
202198
linkUrl: '',
203199
}
@@ -245,7 +241,7 @@ async function getGithubSponsors() {
245241
return []
246242
}
247243

248-
console.error('Failed to fetch GitHub sponsors')
244+
console.error('Failed to fetch GitHub sponsors', err)
249245
}
250246

251247
return sponsors

0 commit comments

Comments
 (0)