13 lines
470 B
TypeScript
13 lines
470 B
TypeScript
import { calculateBalances } from '../../../shared/utils/balances'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const slug = getRouterParam(event, 'slug')!
|
|
|
|
const pot = await getPotOrThrow(slug)
|
|
const participants = await getParticipants(slug)
|
|
const expenses = await getExpensesWithParticipants(slug)
|
|
const { netBalances, settlements } = calculateBalances(participants, expenses)
|
|
|
|
return { pot, participants, expenses, netBalances, settlements }
|
|
})
|