Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions apps/deploy-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const app = new Hono()

app.use('*', cors())

// Global instance for suppabase admin (does not depend on the user)
const supabaseAdmin = createClient<Database>(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!
)

app.post(
'/',
zValidator(
Expand All @@ -49,11 +55,7 @@ app.post(
throw new HTTPException(401, { message: 'Unauthorized' })
}

const supabaseAdmin = createClient<Database>(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!
)

// Only the user's customer is created by Request
const supabase = createClient<Database>(
process.env.SUPABASE_URL!,
process.env.SUPABASE_ANON_KEY!
Expand Down Expand Up @@ -81,11 +83,11 @@ app.post(
} catch (error: unknown) {
console.error(error)
if (error instanceof DeployError) {
throw new HTTPException(500, { message: error.message })
throw new HTTPException(500, { message: (error as Error).message })
}
if (error instanceof IntegrationRevokedError) {
await revokeIntegration(ctx, { integrationId })
throw new HTTPException(406, { message: error.message })
// It is not necessary to wait for the revocation to respond to respond void revokeIntegration(ctx, { integrationId })
throw new HTTPException(406, { message: (error as Error).message })
}
throw new HTTPException(500, { message: 'Internal server error' })
}
Expand Down