feat: add extensive test suite
This commit is contained in:
+4
-14
@@ -2,21 +2,11 @@ import { eq } from "drizzle-orm";
|
||||
import { notFound } from "next/navigation";
|
||||
import { db } from "@/lib/db";
|
||||
import { cdn } from "@/lib/db/schema";
|
||||
import { createCdnHandler } from "@/lib/server-handlers";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
_req: Request,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const { id } = await params;
|
||||
export const GET = createCdnHandler(async (id) => {
|
||||
const [file] = await db.select().from(cdn).where(eq(cdn.id, id)).limit(1);
|
||||
if (!file) return notFound();
|
||||
return new Response(new Uint8Array(file.data), {
|
||||
headers: {
|
||||
"Content-Type": file.type,
|
||||
"Content-Length": file.size,
|
||||
"Cache-Control": "public, max-age=31536000, immutable",
|
||||
},
|
||||
});
|
||||
}
|
||||
return file ? { ...file, data: new Uint8Array(file.data) } : null;
|
||||
}, notFound);
|
||||
|
||||
Reference in New Issue
Block a user