forked from Northgate-Systems/RemitX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.ts
More file actions
22 lines (19 loc) · 703 Bytes
/
Copy pathroute.ts
File metadata and controls
22 lines (19 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { getCurrentUser } from "@/lib/auth";
import { getAccountBalances } from "@/lib/stellar";
import { successResponse, errorResponse, unauthorizedResponse } from "@/lib/api-response";
export async function GET() {
try {
const user = await getCurrentUser();
if (!user) {
return unauthorizedResponse();
}
if (!user.stellarPublicKey) {
return successResponse({ activated: false, balances: [] });
}
const balances = await getAccountBalances(user.stellarPublicKey);
return successResponse({ activated: true, balances });
} catch (err) {
console.error("Balance fetch error:", err);
return errorResponse("Failed to fetch account balance", 500);
}
}