🚧 Migrate env variables to use internal SvelteKit system
Some API fetching function rewriting needed as privates cannot be included into public code
This commit is contained in:
23
src/routes/api/data/+server.ts
Normal file
23
src/routes/api/data/+server.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { error } from '@sveltejs/kit'
|
||||
import type { RequestHandler } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
|
||||
export const POST: RequestHandler = async ({ request }) => {
|
||||
try {
|
||||
const body = await request.text()
|
||||
|
||||
if (body) {
|
||||
const req = await fetchAPI(body)
|
||||
const res = await req
|
||||
|
||||
if (res) {
|
||||
return new Response(JSON.stringify({
|
||||
...res
|
||||
}))
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
throw error(500, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user