Files
medusa-store/www/apps/api-reference/app/api/download/[area]/route.ts
Shahed Nasser 22f30f54fd docs: update api-reference project for v2 (#7307)
* remove everything v1 and make v2 default

* move main v2 rewrites to book

* move rewrites to book + other fixes
2024-05-16 09:02:35 +02:00

30 lines
671 B
TypeScript

import { existsSync, readFileSync } from "fs"
import { NextResponse } from "next/server"
import path from "path"
type DownloadParams = {
params: {
area: string
}
}
export function GET(request: Request, { params }: DownloadParams) {
const { area } = params
const filePath = path.join(process.cwd(), "specs", area, "openapi.full.yaml")
if (!existsSync(filePath)) {
return new NextResponse(null, {
status: 404,
})
}
const fileContent = readFileSync(filePath)
return new Response(fileContent, {
headers: {
"Content-Type": "application/x-yaml",
"Content-Disposition": `attachment; filename="openapi.yaml"`,
},
})
}