feat: bootstrap auto virtual tryon admin frontend
This commit is contained in:
32
app/api/orders/[orderId]/route.ts
Normal file
32
app/api/orders/[orderId]/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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",
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user