Skip to content

Commit

Permalink
Merge pull request #1022 from hackclub/malted/img
Browse files Browse the repository at this point in the history
malted/img
  • Loading branch information
malted authored Dec 22, 2024
2 parents 63d0643 + 1f197b9 commit 2293014
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/app/api/stats/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY }).base(
process.env.BASE_ID!,
)

export async function GET() {
export async function GET({ url }) {
let shipCount = await kv.get('ship-count')
console.log({ shipCount })

if (!shipCount) {
console.log('Refetching ships')
const allShips = await base('ships').select({}).all()
shipCount = allShips.length.toString()
await kv.set('ship-count', shipCount, { ex: 60_000, nx: true })
}
console.log({ shipCount })

const darkTheme = new URL(url).searchParams.get('theme') === 'dark'

return new ImageResponse(
(
<div
style={{
fontSize: 32,
color: 'black',
background: 'white',
color: darkTheme ? 'white' : 'black',
background: 'transparent',
width: '100%',
height: '100%',
padding: '50px 200px',
Expand Down

0 comments on commit 2293014

Please sign in to comment.