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
21 lines (17 loc) · 778 Bytes
/
Copy pathroute.ts
File metadata and controls
21 lines (17 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { NextRequest } from "next/server";
import { getCurrentUser } from "@/lib/auth";
import { listAnchors, estimateFee } from "@/lib/anchors";
import { successResponse, unauthorizedResponse } from "@/lib/api-response";
export async function GET(request: NextRequest) {
const user = await getCurrentUser();
if (!user) return unauthorizedResponse();
const { searchParams } = new URL(request.url);
const corridor = searchParams.get("corridor") || undefined;
const assetCode = searchParams.get("assetCode") || undefined;
const amount = parseFloat(searchParams.get("amount") || "1000");
const anchors = listAnchors({ corridor, assetCode }).map((a) => ({
...a,
estimatedFee: estimateFee(a, amount),
}));
return successResponse({ anchors, amount });
}