Files
medusa-store/www/apps/api-reference/app/download/[area]/route.ts
T
Shahed Nasser 88f2d17a24 docs: change configurations to make v2 the main docs (#9729)
* docs: change configurations to make v2 the main docs

* move api routes to top level

* remove api prefix

* update opengraph images

* show v1 link

* add redirect to v1
2024-10-24 14:49:58 +03: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"`,
},
})
}