19 lines
707 B
TypeScript
19 lines
707 B
TypeScript
import { jsonError, jsonOk } from "@/lib/server/api";
|
|
import { authenticatePublicApiRequest } from "@/lib/server/public-api-auth";
|
|
import { getPublicApiAsset } from "@/lib/server/public-api-assets";
|
|
import { publicApiError } from "@/lib/server/public-api-response";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
export async function GET(request: Request, context: { params: Promise<{ id: string }> }) {
|
|
try {
|
|
const client = authenticatePublicApiRequest(request);
|
|
const { id } = await context.params;
|
|
const asset = await getPublicApiAsset(client.id, id);
|
|
if (!asset) return jsonError("Asset not found.", 404);
|
|
return jsonOk({ asset });
|
|
} catch (error) {
|
|
return publicApiError(error);
|
|
}
|
|
}
|