25 lines
592 B
TypeScript
25 lines
592 B
TypeScript
import { error } from '@sveltejs/kit'
|
|
import { fetchAPI } from '$utils/api'
|
|
|
|
|
|
export const POST = async ({ request, setHeaders }) => {
|
|
try {
|
|
const body = await request.text()
|
|
|
|
if (body) {
|
|
const req = await fetchAPI(body)
|
|
const res = await req
|
|
|
|
if (res) {
|
|
setHeaders({ 'Cache-Control': 'public, max-age=1, stale-while-revalidate=59' })
|
|
|
|
return new Response(JSON.stringify({
|
|
...res
|
|
}))
|
|
}
|
|
}
|
|
} catch (err) {
|
|
error(500, err.message)
|
|
}
|
|
}
|