This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { NextResponse } from "next/server";
|
||||
import { errorResponse } from "../../../../../lib/http";
|
||||
import { projectRoot, touchProject } from "../../../../../lib/storage";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function GET(_: Request, context: { params: Promise<{ projectId: string; file: string }> }) {
|
||||
try {
|
||||
const { projectId, file } = await context.params;
|
||||
if (file !== "minitool.zip") throw new Error("Unknown artifact");
|
||||
await touchProject(projectId);
|
||||
const data = await fs.readFile(path.join(projectRoot(projectId), "artifacts", file));
|
||||
return new NextResponse(data, { headers: { "Content-Type": "application/zip", "Content-Disposition": `attachment; filename="${projectId}-minitool.zip"` } });
|
||||
} catch (error) { return errorResponse(error); }
|
||||
}
|
||||
Reference in New Issue
Block a user