Init commit!

This commit is contained in:
Jennie Robinson Faber 2025-08-22 18:36:16 +01:00
commit 086d682592
34 changed files with 19249 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import { getCollection } from '../../utils/db.js'
export default defineEventHandler(async (event) => {
try {
const collection = await getCollection('transactions')
const transactions = await collection.find({}).toArray()
// Convert MongoDB _id to id for frontend compatibility
const formattedTransactions = transactions.map(transaction => ({
...transaction,
id: transaction._id.toString(),
_id: undefined
}))
return formattedTransactions
} catch (error) {
console.error('Error fetching transactions:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch transactions'
})
}
})