Skip to content

Commit d435c80

Browse files
author
Nathan Shepherd
committed
fix: build failure — module-level Supabase init in invite/scheduler routes
- /api/invite/[token]: add force-dynamic + lazy init (was crashing next build) - /api/scheduler/tick: lazy init via Proxy (module-level createClient fails without env) - app/page.tsx: fix JSX syntax error (array literal missing {} wrapper) - lib/onboarding.ts: fix .catch() TS error These were blocking ALL deployments since ee2892a.
1 parent 6212b08 commit d435c80

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

tap-dashboard/app/api/invite/[token]/route.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
export const dynamic = 'force-dynamic';
12
import { NextRequest, NextResponse } from 'next/server'
23
import { createClient } from '@supabase/supabase-js'
34

4-
const supabase = createClient(
5-
process.env.NEXT_PUBLIC_SUPABASE_URL!,
6-
process.env.SUPABASE_SERVICE_ROLE_KEY!
7-
)
5+
function getSupabase() {
6+
return createClient(
7+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
8+
process.env.SUPABASE_SERVICE_ROLE_KEY!
9+
)
10+
}
811

912
export async function GET(
1013
req: NextRequest,
@@ -16,7 +19,7 @@ export async function GET(
1619
return new NextResponse('Missing token', { status: 400 })
1720
}
1821

19-
const { data, error } = await supabase
22+
const { data, error } = await getSupabase()
2023
.from('agent_invite_tokens')
2124
.select('*')
2225
.eq('token', token)
@@ -51,7 +54,7 @@ export async function GET(
5154

5255
// Mark claimed (but don't block repeat reads — agent may need to re-read)
5356
if (!data.claimed_at) {
54-
await supabase
57+
await getSupabase()
5558
.from('agent_invite_tokens')
5659
.update({ claimed_at: new Date().toISOString() })
5760
.eq('token', token)

tap-dashboard/app/api/scheduler/tick/route.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
export const dynamic = 'force-dynamic';
12
import { NextRequest, NextResponse } from 'next/server'
23
import { createClient } from '@supabase/supabase-js'
34

4-
const supabase = createClient(
5-
process.env.NEXT_PUBLIC_SUPABASE_URL!,
6-
process.env.SUPABASE_SERVICE_ROLE_KEY!
7-
)
5+
let _sb: ReturnType<typeof createClient> | null = null
6+
function getSupabase() {
7+
if (!_sb) _sb = createClient(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!)
8+
return _sb
9+
}
10+
const supabase = new Proxy({} as ReturnType<typeof createClient>, {
11+
get: (_target, prop) => (getSupabase() as any)[prop],
12+
})
813

914
const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://moltos.xyz'
1015

tap-dashboard/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default async function HomePage() {
154154
</p>
155155
</div>
156156
<div className="grid grid-cols-2 gap-3 flex-shrink-0">
157-
[
157+
{[
158158
{ label: '74 registered agents', sub: `32 active · avg TAP ${stats.avgReputation || 438}`, color: 'text-accent-violet', border: 'border-accent-violet/30' },
159159
{ label: '$72.80 paid out', sub: '20 completed jobs · 10 open now', color: 'text-[#00E676]', border: 'border-[#00E676]/30' },
160160
{ label: 'Cross-Platform', sub: 'Runable + Kimi · real Stripe escrow', color: 'text-[#00E676]', border: 'border-[#00E676]/30' },

tap-dashboard/lib/onboarding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export async function seedOnboarding(agentId: string): Promise<void> {
8181
if (error) {
8282
// Constraint may not exist yet — try individual inserts
8383
for (const task of tasks) {
84-
await sb.from('bootstrap_tasks').insert(task).then(() => {}).catch(() => {})
84+
try { await sb.from('bootstrap_tasks').insert(task) } catch { /* ignore */ }
8585
}
8686
}
8787
} catch {

0 commit comments

Comments
 (0)