mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
* feat(notification): slack, email, webhook notifications from logs * retain search params for filters to link in notification * add alerting rules * update selector * fix lint * add limits on num of emails and notification triggers per workspace * address greptile comments * add search to combobox * move notifications to react query * fix lint * fix email formatting * add more alert types * fix imports * fix test route * use emcn componentfor modal * refactor: consolidate notification config fields into jsonb objects * regen migration * fix delete notif modal ui * make them multiselect dropdowns * update tag styling * combobox font size with multiselect tags'
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { db } from '@sim/db'
|
|
import { account } from '@sim/db/schema'
|
|
import { and, eq } from 'drizzle-orm'
|
|
import { type NextRequest, NextResponse } from 'next/server'
|
|
import { getSession } from '@/lib/auth'
|
|
import { createLogger } from '@/lib/logs/console/logger'
|
|
|
|
const logger = createLogger('AuthAccountsAPI')
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const session = await getSession()
|
|
if (!session?.user?.id) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { searchParams } = new URL(request.url)
|
|
const provider = searchParams.get('provider')
|
|
|
|
const whereConditions = [eq(account.userId, session.user.id)]
|
|
|
|
if (provider) {
|
|
whereConditions.push(eq(account.providerId, provider))
|
|
}
|
|
|
|
const accounts = await db
|
|
.select({
|
|
id: account.id,
|
|
accountId: account.accountId,
|
|
providerId: account.providerId,
|
|
})
|
|
.from(account)
|
|
.where(and(...whereConditions))
|
|
|
|
return NextResponse.json({ accounts })
|
|
} catch (error) {
|
|
logger.error('Failed to fetch accounts', { error })
|
|
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
|
|
}
|
|
}
|