mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 11:31:46 +00:00
clean up
This commit is contained in:
parent
f2f702099f
commit
3a105c79dd
@ -2,11 +2,9 @@ import type { APIResponse } from "$lib/interfaces";
|
|||||||
import { json, type RequestHandler } from "@sveltejs/kit";
|
import { json, type RequestHandler } from "@sveltejs/kit";
|
||||||
|
|
||||||
export const GET: RequestHandler = async ({ url }) => {
|
export const GET: RequestHandler = async ({ url }) => {
|
||||||
const response = { success: false } as APIResponse;
|
|
||||||
|
|
||||||
const params = url.searchParams;
|
const params = url.searchParams;
|
||||||
const endpoint = params.get('endpoint');
|
const endpoint = params.get('endpoint');
|
||||||
if (endpoint === null) return json(response);
|
if (endpoint === null) return json({ success: false } as APIResponse);
|
||||||
|
|
||||||
const api_call = await fetch(`http://localhost:8080/${endpoint}`);
|
const api_call = await fetch(`http://localhost:8080/${endpoint}`);
|
||||||
const data = await api_call.json() as APIResponse;
|
const data = await api_call.json() as APIResponse;
|
||||||
@ -14,11 +12,9 @@ export const GET: RequestHandler = async ({ url }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const POST: RequestHandler = async ({ request }) => {
|
export const POST: RequestHandler = async ({ request }) => {
|
||||||
const response = { success: false } as APIResponse;
|
|
||||||
|
|
||||||
const formData = await request.formData();
|
const formData = await request.formData();
|
||||||
const endpoint = formData.get('endpoint');
|
const endpoint = formData.get('endpoint');
|
||||||
if (endpoint === null) return json(response);
|
if (endpoint === null) return json({ success: false } as APIResponse);
|
||||||
|
|
||||||
formData.delete('endpoint');
|
formData.delete('endpoint');
|
||||||
const api_call = await fetch(`http://localhost:8080/${endpoint}`, {
|
const api_call = await fetch(`http://localhost:8080/${endpoint}`, {
|
||||||
|
Loading…
Reference in New Issue
Block a user