33 lines
960 B
TypeScript
33 lines
960 B
TypeScript
import { adaptOrderDetail } from "@/lib/adapters/orders";
|
|
import { backendRequest } from "@/lib/http/backend-client";
|
|
import {
|
|
jsonSuccess,
|
|
parsePositiveIntegerParam,
|
|
withErrorHandling,
|
|
} from "@/lib/http/response";
|
|
import type { AssetDto, OrderDetailResponseDto } from "@/lib/types/backend";
|
|
|
|
type RouteContext = {
|
|
params: Promise<{
|
|
orderId: string;
|
|
}>;
|
|
};
|
|
|
|
export async function GET(_request: Request, context: RouteContext) {
|
|
return withErrorHandling(async () => {
|
|
const { orderId: rawOrderId } = await context.params;
|
|
const orderId = parsePositiveIntegerParam(rawOrderId, "orderId");
|
|
const [orderResponse, assetsResponse] = await Promise.all([
|
|
backendRequest<OrderDetailResponseDto>(`/orders/${orderId}`),
|
|
backendRequest<AssetDto[]>(`/orders/${orderId}/assets`),
|
|
]);
|
|
|
|
return jsonSuccess(
|
|
adaptOrderDetail(orderResponse.data, assetsResponse.data),
|
|
{
|
|
mode: "proxy",
|
|
},
|
|
);
|
|
});
|
|
}
|