File size: 464 Bytes
13daa38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { NextResponse } from 'next/server'
import { readFileSync } from 'fs'
import { join } from 'path'

let cachedSpec: string | null = null

export async function GET() {
  if (!cachedSpec) {
    const specPath = join(process.cwd(), 'openapi.json')
    cachedSpec = readFileSync(specPath, 'utf-8')
  }

  return new NextResponse(cachedSpec, {
    headers: {
      'Content-Type': 'application/json',
      'Cache-Control': 'public, max-age=3600',
    },
  })
}