Upgrade SvelteKit 4 to SvelteKit 5 with latest dependencies
Major changes: - Upgraded Svelte from v4 to v5.38.6 (latest stable) - Upgraded SvelteKit from v2.0.0 to v2.37.0 (latest) - Upgraded Vite from v5 to v7.1.3 for better performance - Updated all related packages to latest compatible versions - Added pnpm as package manager with packageManager field - Fixed Card.svelte nested anchor tags issue by converting inner links to buttons - Updated component styling to maintain visual consistency - Removed incompatible svelte-preprocess-import-assets package Dependencies updated: - @sveltejs/kit: ^2.0.0 → ^2.37.0 - @sveltejs/vite-plugin-svelte: ^3.0.0 → ^6.1.3 - svelte: ^4.0.0 → ^5.38.6 - vite: ^5.0.0 → ^7.1.3 - @sveltejs/adapter-auto: ^3.0.0 → ^6.1.0 - @sveltejs/adapter-node: ^2.0.0 → ^5.0.0 - svelte-check: ^3.4.6 → ^4.0.0 - mongoose: ^7.4.0 → ^8.0.0 - sharp: ^0.32.3 → ^0.33.0 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
src/routes/api/cospend/balance/+server.ts
Normal file
38
src/routes/api/cospend/balance/+server.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { Payment } from '$lib/models/Payment'; // adjust path as needed
|
||||
import { dbConnect, dbDisconnect } from '$lib/db/db';
|
||||
|
||||
const UPLOAD_DIR = '/var/lib/www/static/test';
|
||||
const BASE_CURRENCY = 'CHF'; // Default currency
|
||||
|
||||
export const GET: RequestHandler = async ({ request, locals }) => {
|
||||
await dbConnect();
|
||||
|
||||
const result = await Payment.aggregate([
|
||||
{
|
||||
$group: {
|
||||
_id: "$paid_by",
|
||||
totalPaid: { $sum: "$total_amount" },
|
||||
totalForSelf: { $sum: { $ifNull: ["$for_self", 0] } },
|
||||
totalForOther: { $sum: { $ifNull: ["$for_other", 0] } }
|
||||
}
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
paid_by: "$_id",
|
||||
netTotal: {
|
||||
$multiply: [
|
||||
{ $add: [
|
||||
{ $subtract: ["$totalPaid", "$totalForSelf"] },
|
||||
"$totalForOther"
|
||||
] },
|
||||
0.5]
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
await dbDisconnect();
|
||||
return json(result);
|
||||
};
|
||||
Reference in New Issue
Block a user