16 lines
562 B
TypeScript
16 lines
562 B
TypeScript
import { buildPortfolioSummary } from '@/lib/server/portfolio';
|
|
import { requireAuthenticatedSession } from '@/lib/server/auth-session';
|
|
import { getStoreSnapshot } from '@/lib/server/store';
|
|
|
|
export async function GET() {
|
|
const { session, response } = await requireAuthenticatedSession();
|
|
if (response) {
|
|
return response;
|
|
}
|
|
|
|
const userId = session.user.id;
|
|
const snapshot = await getStoreSnapshot();
|
|
const summary = buildPortfolioSummary(snapshot.holdings.filter((holding) => holding.user_id === userId));
|
|
return Response.json({ summary });
|
|
}
|