forked from FlowwStar/FlowStar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.tsx
More file actions
160 lines (150 loc) · 4.62 KB
/
Copy pathroute.tsx
File metadata and controls
160 lines (150 loc) · 4.62 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { ImageResponse } from '@vercel/og'
export const runtime = 'edge'
interface OGParams {
amount?: string
symbol?: string
recipient?: string
sender?: string
status?: string
}
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url)
const params: OGParams = {
amount: searchParams.get('amount') || '0',
symbol: searchParams.get('symbol') || 'XLM',
recipient: searchParams.get('recipient') || '',
sender: searchParams.get('sender') || '',
status: searchParams.get('status') || 'active',
}
const shortenAddress = (addr: string) => {
if (!addr) return ''
return addr.slice(0, 6) + '...' + addr.slice(-4)
}
return new ImageResponse(
(
<div
style={{
fontSize: 48,
background: 'linear-gradient(135deg, #0c1014 0%, #1a202c 100%)',
width: '100%',
height: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
fontFamily: 'system-ui, -apple-system, sans-serif',
color: 'white',
padding: '40px',
}}
>
{/* Logo / Header */}
<div
style={{
fontSize: 64,
fontWeight: 'bold',
marginBottom: 40,
background: 'linear-gradient(90deg, #60a5fa 0%, #3b82f6 100%)',
backgroundClip: 'text',
WebkitBackgroundClip: 'text',
WebkitTextFillColor: 'transparent',
}}
>
FlowStar
</div>
{/* Main Content */}
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: 24,
alignItems: 'center',
textAlign: 'center',
}}
>
{/* Amount */}
<div
style={{
fontSize: 56,
fontWeight: 'bold',
color: '#60a5fa',
}}
>
{params.amount} {params.symbol}
</div>
{/* Status Badge */}
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 12,
padding: '8px 24px',
borderRadius: 24,
background: params.status === 'active' ? 'rgba(96, 165, 250, 0.2)' : 'rgba(107, 114, 128, 0.2)',
border: `2px solid ${params.status === 'active' ? '#60a5fa' : '#6b7280'}`,
}}
>
<span
style={{
width: 12,
height: 12,
borderRadius: '50%',
background: params.status === 'active' ? '#60a5fa' : '#6b7280',
}}
/>
<span style={{ fontSize: 24, textTransform: 'capitalize' }}>
{params.status}
</span>
</div>
{/* Addresses */}
<div
style={{
display: 'flex',
gap: 32,
justifyContent: 'center',
fontSize: 20,
color: '#9ca3af',
width: '100%',
flexWrap: 'wrap',
}}
>
{params.sender && (
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
<span style={{ fontSize: 16, color: '#6b7280' }}>From</span>
<span style={{ fontFamily: 'monospace', color: '#e5e7eb' }}>
{shortenAddress(params.sender)}
</span>
</div>
)}
{params.recipient && (
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
<span style={{ fontSize: 16, color: '#6b7280' }}>To</span>
<span style={{ fontFamily: 'monospace', color: '#e5e7eb' }}>
{shortenAddress(params.recipient)}
</span>
</div>
)}
</div>
</div>
{/* Footer */}
<div
style={{
marginTop: 60,
fontSize: 20,
color: '#6b7280',
}}
>
Stream tokens by the second on Stellar
</div>
</div>
),
{
width: 1200,
height: 630,
},
)
} catch (error) {
console.error('OG image generation error:', error)
return new Response('Failed to generate OG image', { status: 500 })
}
}