mirror of
https://github.com/acedanger/finance.git
synced 2025-12-05 22:50:12 -08:00
- Remove in-memory store and related tests - Add Decimal to number conversion in API responses - Update integration tests to handle Prisma Decimal type - Fix test configuration to only run db-integration tests
30 lines
902 B
TypeScript
30 lines
902 B
TypeScript
import type { APIRoute } from 'astro';
|
|
import { transactionService } from '../../../../../data/db.service';
|
|
|
|
export const GET: APIRoute = async ({ params }) => {
|
|
try {
|
|
const accountTransactions = await transactionService.getByAccountId(params.id as string);
|
|
|
|
// Convert Decimal to number for each transaction in response
|
|
const response = accountTransactions.map((transaction) => ({
|
|
...transaction,
|
|
amount: Number(transaction.amount),
|
|
}));
|
|
|
|
return new Response(JSON.stringify(response), {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
} catch (error) {
|
|
console.error('Error fetching account transactions:', error);
|
|
return new Response(JSON.stringify({ error: 'Failed to fetch account transactions' }), {
|
|
status: 500,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
}
|
|
};
|